Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Peer
  • COMPETE
    • September Algorithm Challenge
    • August Cook-Off 02
    • August Algorithm Challenge
    • July Cook-Off 01
    • January Algorithm Challenge
  • DISCUSS
    • Wiki
    • Forums
    • Blog
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Ranks
    • Tutorials
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • About Directi
Home » Compete » February 2010 Contest » Overlapping discs

Overlapping discs

Problem code: M5

  • All Submissions

All submissions for this problem are available.

The problem statement has been updated.

The time limit for this problem is now 5 seconds.

You are given n discs on plane, of the same radius (r=1). Output the area of the part of the plane which is covered by each disc.

Input

First, 1<=t<=10, the number of tests. Each testcase is of the following form: 1<=n<=100000, then n pairs of floating point coordinates follow: -1000<=xi,yi<=1000, representing the location of the i-th disc.

Output

For each testcase, output the total area covered by the intersection of all discs. Round the answer to 6 decimal digits after the point.

Example

Input:
1
2
0 0
0 1

Output:
1.228370

Date: 2010-01-29
Time limit: s
Source limit: 50000
Languages:


  • Submit

Comments

  • Login or Register to post a comment.

I am pretty sure that my

Mislav Balunovic - 1st Feb,2010 15:54:39.

I am pretty sure that my solution is correct, but I somehow

get SIGSEGV...

Are you sure both xi, yi are not greater than 1000 in test cases?

This is part of my code:

Mislav Balunovic - 1st Feb,2010 16:01:02.

This is part of my code:

  • if ( x > 1000 || y > 1000 ){
  • sol = -123456;
  • printf("12334455n");
  • return;
  • }
  • Indeed, now I get wrong answer instead of runtime error.

    Please check test cases.

    Wrong Answer why .. ? My

    Aman - 1st Feb,2010 16:06:46.

    Wrong Answer why .. ? My solution is correct :(


    Checking.

    Admin - 1st Feb,2010 16:13:09.

    Checking.

    what should be the value of

    Aman - 1st Feb,2010 16:19:10.

    what should be the value of PI .. ?

    There has only ever been one

    Stephen Merriman - 1st Feb,2010 16:27:03.

    There has only ever been one value of pi, and always will be.

    The test cases are correct.

    Admin - 1st Feb,2010 16:49:37.

    The test cases are correct.

    Please clarify if  PI be 3.14

    Sandy - 1st Feb,2010 19:36:51.

    Please clarify if  PI be 3.14 or 3.1416 or having more sognificant figures .

    @Lucky: Try 2.0*acos(0.0)

    Muhammed Hedayetul Islam - 1st Feb,2010 19:48:34.

    @Lucky: Try 2.0*acos(0.0)

    I am sorry, I understood

    Mislav Balunovic - 1st Feb,2010 22:28:10.

    I am sorry, I understood numbers are integers because of

    sample test cases in text...

    IMPORTANT:   I changed

    Przemysław Uznański - 2nd Feb,2010 05:19:06.

    IMPORTANT:

     

    I changed expected precision up to 6 digits after decimal.

    MORE IMPORTANT:   This

    Przemysław Uznański - 2nd Feb,2010 05:45:26.

    MORE IMPORTANT:

     

    This problem is all about INTERSECTION of discs, not UNION of discs. I have no privileges to change it, lets hope some admin do it soon.

    @Przemysław:  I really love

    David Stolp - 2nd Feb,2010 06:43:15.

    @Przemysław:  I really love most of your problems.  Very challenging.  But having to deal with significant changes to the problem statement (and especially changes to the judge) can be very annoying.  It seems you're suggesting that the entire problem statement (as well as sample i/o) is completely wrong.  How does such a mistake not get caught before the contest?

    Which way should 0.1234565 be

    Tomek Czajka - 2nd Feb,2010 10:33:01.

    Which way should 0.1234565 be rounded to six decimal places, up or down?

    @Przemysławare are you the

    ?? - 2nd Feb,2010 12:46:36.

    @Przemysławare are you the problem setter?

    But the sample input and output here looks as if its a union not intersection?

    Surely it can't be possible

    Stephen Merriman - 2nd Feb,2010 13:49:56.

    Surely it can't be possible that the description, output section, and sample output can all be wrong at the same time.

    @Przemysławare Sample output

    Shashwat Anand - 2nd Feb,2010 15:21:51.

    @Przemysławare

    Sample output is UNION ? Is this wrong ?

    Let us say three circles (A, B, C) intersect each other. So you are suggesting that insteaed of finding (A union B union C) we go for the common area by the three circles i.e. (A intersection B intersection C) or the area due to overlapping i.e. { (A intersection B) + (A intersection C) p+ (B interstion C) -  (A intersection B intersection C) }

    The problem statement as of now is Deceptive to the core .. IMHO, not to mention hard.

    IMPORTANT This problem

    Admin - 2nd Feb,2010 16:09:55.

    IMPORTANT

    This problem statement has been updated.

    I'm glad this is the last

    Brian Drake - 2nd Feb,2010 16:23:27.

    I'm glad this is the last problem I looked at!

    I am seeing:

    Date: 2010-01-29
    Time limit: s
    Source limit: 50000
    Languages:

    Notice that the date is later than on the other problems; more concerning is the missing time limit and languages lists.

    @Mislav The test cases that

    Brian Drake - 2nd Feb,2010 16:27:34.

    @Mislav The test cases that are provided in the problem statement in programming competitions generally do not cover all the important issues.

    Do I understand this

    Brian Drake - 2nd Feb,2010 16:34:14.

    Do I understand this correctly? More than 10 hours, most of them daylight hours, passed between the problem setter releasing a correction and an admin updating the problem statement? I am with David in wondering how these things happen. Only one person has submitted since the problem statement was changed. Hopefully someone will finally crack it, then I'll know it's worth trying.

    @Tomasz   printf("%.6lf",   o

    Przemysław Uznański - 2nd Feb,2010 16:52:10.

    @Tomasz

     

    printf("%.6lf",

     

    ok?

    Time limit is missing, it is

    Przemysław Uznański - 2nd Feb,2010 17:55:59.

    Time limit is missing, it is 2s for all testcases. I have no privileges to upload it to problem statement,

    @Brian I made the change as

    Admin - 2nd Feb,2010 20:54:47.

    @Brian I made the change as soon as I saw the updated statement. Also, you are discounting the difference in time zones :)

    @Przemysław What language is

    Brian Drake - 3rd Feb,2010 11:26:54.

    @Przemysław What language is that statement in? C? There are different flavours of C, even before you count C++ and C#. This problem statement is missing the languages list, as I pointed out before, and CodeChef accepts several variations of C. Not everyone uses C, anyway. I think the original question was reasonable.

    can the coordinates of centre

    Aashish - 3rd Feb,2010 11:47:54.

    can the coordinates of centre be floating point numbers or they are strictly integer?

    and if there are 10 discs then is the area to be calculated is the area common to all 10 of them or is it the sum of individual overlapping areas between any possible set of circles?

     

    admin please clarify

    Your first question is

    Stephen Merriman - 3rd Feb,2010 12:57:02.

    Your first question is already answered.

    You want to find just the area common to all circles.

    @Brian Don't ask admin

    Przemysław Uznański - 3rd Feb,2010 18:11:29.

    @Brian

    Don't ask admin related questions to me, I'm only problemsetter.

    @Aashish   read carefully

    Przemysław Uznański - 3rd Feb,2010 18:13:16.

    @Aashish

     

    read carefully problem statement

    IMPORTANT I increased time

    Przemysław Uznański - 3rd Feb,2010 20:33:38.

    IMPORTANT

    I increased time limits here (5s on largest tests), because even my solution didn't fit into time limit. Sory for troubles, and I wish you nice problem solving from Harbin :)


    a small question is the

    Ahmed Saber - 3rd Feb,2010 22:22:45.

    a small question

    is the common area is always between 2 circles only??

    I mean is it possible that more that 2 circle share the same area??

    @Przemysław: Thank you for

    David Stolp - 4th Feb,2010 00:41:08.

    @Przemysław: Thank you for the increase in time limit.  I was not looking forward to that optimization.

     

    @Admin: Do I need to resubmit my solution to fix the rankings issues?

    am i forced to output the

    Ahmed Saber - 4th Feb,2010 01:03:27.

    am i forced to output the last zeros as the sample output??

    i mean if there is no

    Ahmed Saber - 4th Feb,2010 01:26:40.

    i mean if there is no intersection found then the area is zero

    so the output will be :

    0

    or

    0.000000

    Given the large number of

    Brian Drake - 4th Feb,2010 12:04:00.

    Given the large number of problems with this problem, I'm inclined to ask this: can anyone confirm that the sample output is correct? I did it by hand and got a slightly different answer.

    @Przemysław You responded to

    Brian Drake - 4th Feb,2010 12:08:39.

    @Przemysław You responded to question with the following code fragment: printf("%.6lf",. I was asking what language that code fragment was written in. The answer is obviously C, but there are many different forms of C; does that code behave the same way in all of them? And people who aren't familiar with C still don't know the answer to Tomasz's question.

    None of this is an admin issue.

    @Ahmed: my accepted solution

    David Stolp - 4th Feb,2010 12:15:46.

    @Ahmed: my accepted solution prints exactly 6 digits after the decimal for every test case.

    @Brian: the exact value is 1.228369something, where something is at least 5, and is therefore rounded up to 1.228370

    The phrase 'answer should be

    Przemysław Uznański - 4th Feb,2010 15:41:24.

    The phrase 'answer should be correct up to 6 decimal places' is standard phrase, and is no different from same phrase in hundreds of similar problems on spoj or codechef or other online judges.

    I really shouldn't bother answering that question, and I was kinda suprised that Tomek asked that question. It was or joke, or disbelief in my solution.

    @David So it is, I copied the

    Brian Drake - 4th Feb,2010 16:06:34.

    @David So it is, I copied the value incorrectly from my calculator somehow...

    Can the OP give us one more

    Shashwat Anand - 4th Feb,2010 19:41:35.

    Can the OP give us one more test case: in floating points ofcourse as it's past 3 days with only 1 successful submission.

    @Przemysław: It was a

    Tomek Czajka - 5th Feb,2010 00:18:08.

    @Przemysław:

    It was a semi-joke question. But note that the problem doesn't say "answer should be correct up to 6 decimal places" or "errors up to 1e-6 are allowed". It says "Round the answer to 6 decimal digits after the point." which is more restrictive and means that arbitrary precision might be required to know which way to round.

    i ve submited my code and it

    Aashish - 5th Feb,2010 02:35:48.

    i ve submited my code and it is saying wrong ans though i havechecked that my answers are absolutely correct though it might be taking a little more time then expected

    can that be a possibility?

    hey i m new to code chef this

    Aashish - 5th Feb,2010 03:04:57.

    hey i m new to code chef

    this time i ve got time limit exceeded error can some one clarify tht does it mean my code was error free but violated time limit or it means computer stopped checking it after the specified deadline??

    thanks in advance

    Wrong answers means wrong

    Stephen Merriman - 5th Feb,2010 03:41:53.

    Wrong answers means wrong answer. Not right answer.

    Time limit exceeded means time limit exceeded. Not right answer in too much time.

    FAQ

    @Tomek: I'll try to verify

    Przemysław Uznański - 5th Feb,2010 04:02:21.

    @Tomek: I'll try to verify that small precision errors don't change answer. But maybe after the world finals :P

     

    @Stephen: Thx.

    @Przemek: Good luck.

    Tomek Czajka - 5th Feb,2010 04:38:49.

    @Przemek: Good luck.

    @ admin for ur test cases my

    Aashish - 5th Feb,2010 12:33:28.

    @ admin for ur test cases my ans is correct i.e. 1.228370

     

    if u put number of circles =1 then also ans is the value of pi i.e. 3.141593

    if i shift the coordinates i.e. make 0,0 and 1,0 to 0,0 and -1,0 etc then again my ans is correct 1.228370

    please give us one or two more test cases

    i strongly believe my solution is correct

    It isn't. Come up with your

    Stephen Merriman - 5th Feb,2010 12:55:24.

    It isn't. Come up with your own test cases.

    big confusion with the

    Shrikant - 5th Feb,2010 14:52:17.

    big confusion with the problem statement.. so just one question:

    Do we have to find the area common to EVERY circle(all n circles)?? Yes or No? That will clarify the problem statement very nicely..

    Thanks

    @Shrikant The problem

    Brian Drake - 5th Feb,2010 15:06:34.

    @Shrikant The problem statement says to "... output the total area covered by the intersection of all discs". (emphasis added) The answer to your question is therefore "yes".

    @Brian thanks a lot :)

    Shrikant - 5th Feb,2010 15:40:24.

    @Brian thanks a lot :)

    How many decimal places

    Mislav Balunovic - 6th Feb,2010 15:23:06.

    How many decimal places points in input have?

    @ brian   supppose there are

    Bhavesh Jaisinghani - 7th Feb,2010 17:21:21.

    @ brian   supppose there are 10 discs .....and the maximum no of disc that are intersected to each other are 5 ...so do we have to find that area of 5 intersected discs  or  the loop comes out and say that not all the discs are intersecting so program terminated .....

    @Bhavesh You always need to

    Brian Drake - 7th Feb,2010 18:01:28.

    @Bhavesh You always need to output an answer! In this case, the answer is zero. According to the answers above, you need to output "0.000000" (without the quotes).

    spoj checker uses scanf to

    Przemysław Uznański - 8th Feb,2010 23:39:29.

    spoj checker uses scanf to test outputs, so it is really no difference if you output 0, or 0.000, or -0.000000

    Sometimes I get WA with 21

    Tasnim khan - 10th Feb,2010 04:15:54.

    Sometimes I get WA with 21 seconds;

    Sometimes I get TLE

    Sometimes WA with 16 and so on....

    Is time limit really very strict here ?

    What is displayed as result

    Tomaz Hocevar - 10th Feb,2010 04:59:05.

    What is displayed as result when there are multiple input files? Is it type of error for first input, which is not accepted(TLE, WA, ...)? Or does our solution have to pass all inputs within time limit and only then are outputs checked for wrong answers?

    I don't think so it's a error

    Tasnim khan - 10th Feb,2010 05:23:16.

    I don't think so it's a error for first file....

    After checking so many times .. I have confirmed that my solution is getting stuck in near to last cases

    m newbie here its my first

    anant mittal - 10th Feb,2010 16:44:08.

    m newbie here

    its my first time

    can u please tell me how to take input

    whether as .txt file or somhw else???

    @Tomaz I believe the result

    Brian Drake - 11th Feb,2010 13:22:31.

    @Tomaz I believe the result displayed is the type of error for the first input that fails. See the FAQ.

    Directi Go for Gold

    SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

    Fetching successful submissions
    CodeChef is a non-commercial competitive programming community
    • About CodeChef
    • About Directi
    • CEO's Corner
    • feedback@codechef.com
    © 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
    Sponsors
    The time now is: