< Back to forum

codeforces

question: http://codeforces.com/contest/994/problem/C

please give hints, how to approach this problem..!!

Thank You

Asked by: Samrat_De on April 7, 2019, 6:34 p.m. Last updated on April 7, 2019, 6:34 p.m.


Enter your answer details below:


Enter your comment details below:




1 Answer(s)

avatar

you can solve the subproblem first. the subproblem is to find that a point lies inside a square or not. for that, you can use area comparison method.

now you have to generate the center of each square and run the above function for both the squares in which you pass all the five points (four corners and one center, one by one) with the other square and if it returns true that means the two squares intersect else we run the function with other points. there are total (5+5) function calls we have to perform. if any of them is true then answer is yes else no.

if you have difficulty to understand this approach then try to draw some diagrams that would help.

note :) you can also use another approach which uses some successive conditional checking but it's too complex and I don't think that implementing it in short contest is a good idea, but I give some idea about that.

condition 1:- check if x segment of both squares intersect or not. if no then answer is no else go next condition.

condition 1:- check if y segment of both squares intersect or not. if no then answer is no else go next condition.

and so on some more conditions...

rishup132 last updated on April 7, 2019, 6:34 p.m. 0    Reply    Upvote   

Instruction to write good question
  1. 1. Write a title that summarizes the specific problem
  2. 2. Pretend you're talking to a busy colleague
  3. 3. Spelling, grammar and punctuation are important!

Bad: C# Math Confusion
Good: Why does using float instead of int give me different results when all of my inputs are integers?
Bad: [php] session doubt
Good: How can I redirect users to different pages based on session data in PHP?
Bad: android if else problems
Good: Why does str == "value" evaluate to false when str is set to "value"?

Refer to Stack Overflow guide on asking a good question.