CodeChef is a non-commercial competitive programming community
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
    • Challenge
    • Peer
  • COMPETE
    • February CookOff
    • February Long Contest
    • January CookOff
  • DISCUSS
    • Wiki
    • Forums
    • Blog
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
    • Event Calendar
  • 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
    • Contact Us
    • 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

mbalunovic @ 1 Feb 2010 03:54 PM

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:

mbalunovic @ 1 Feb 2010 04:01 PM

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

    fat0ss @ 1 Feb 2010 04:06 PM

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


    Checking.

    admin @ 1 Feb 2010 04:13 PM

    Checking.

    what should be the value of

    fat0ss @ 1 Feb 2010 04:19 PM

    what should be the value of PI .. ?

    There has only ever been one

    triplem @ 1 Feb 2010 04:27 PM

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

    The test cases are correct.

    admin @ 1 Feb 2010 04:49 PM

    The test cases are correct.

    Please clarify if  PI be 3.14

    alok @ 1 Feb 2010 07:36 PM

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

    @Lucky: Try 2.0*acos(0.0)

    Muhammed Hedayet @ 1 Feb 2010 07:48 PM

    @Lucky: Try 2.0*acos(0.0)

    I am sorry, I understood

    mbalunovic @ 1 Feb 2010 10:28 PM

    I am sorry, I understood numbers are integers because of

    sample test cases in text...

    IMPORTANT:   I changed

    izulin @ 2 Feb 2010 05:19 AM

    IMPORTANT:

     

    I changed expected precision up to 6 digits after decimal.

    MORE IMPORTANT:   This

    izulin @ 2 Feb 2010 05:45 AM

    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

    pieguy @ 2 Feb 2010 06:43 AM

    @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 @ 2 Feb 2010 10:33 AM

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

    @Przemysławare are you the

    foofoo @ 2 Feb 2010 12:46 PM

    @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

    triplem @ 2 Feb 2010 01:49 PM

    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

    l0nwlf @ 2 Feb 2010 03:21 PM

    @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 @ 2 Feb 2010 04:09 PM

    IMPORTANT

    This problem statement has been updated.

    I'm glad this is the last

    Brian Drake @ 2 Feb 2010 04:23 PM

    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 @ 2 Feb 2010 04:27 PM

    @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 @ 2 Feb 2010 04:34 PM

    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

    izulin @ 2 Feb 2010 04:52 PM

    @Tomasz

     

    printf("%.6lf",

     

    ok?

    Time limit is missing, it is

    izulin @ 2 Feb 2010 05:55 PM

    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 @ 2 Feb 2010 08:54 PM

    @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 @ 3 Feb 2010 11:26 AM

    @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

    maximus1988 @ 3 Feb 2010 11:47 AM

    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

    triplem @ 3 Feb 2010 12:57 PM

    Your first question is already answered.

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

    @Brian Don't ask admin

    izulin @ 3 Feb 2010 06:11 PM

    @Brian

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

    @Aashish   read carefully

    izulin @ 3 Feb 2010 06:13 PM

    @Aashish

     

    read carefully problem statement

    IMPORTANT I increased time

    izulin @ 3 Feb 2010 08:33 PM

    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

    thesane @ 3 Feb 2010 10:22 PM

    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

    pieguy @ 4 Feb 2010 12:41 AM

    @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

    thesane @ 4 Feb 2010 01:03 AM

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

    i mean if there is no

    thesane @ 4 Feb 2010 01:26 AM

    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 @ 4 Feb 2010 12:04 PM

    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 @ 4 Feb 2010 12:08 PM

    @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

    pieguy @ 4 Feb 2010 12:15 PM

    @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

    izulin @ 4 Feb 2010 03:41 PM

    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 @ 4 Feb 2010 04:06 PM

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

    Can the OP give us one more

    l0nwlf @ 4 Feb 2010 07:41 PM

    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 @ 5 Feb 2010 12:18 AM

    @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

    maximus1988 @ 5 Feb 2010 02:35 AM

    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

    maximus1988 @ 5 Feb 2010 03:04 AM

    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

    triplem @ 5 Feb 2010 03:41 AM

    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

    izulin @ 5 Feb 2010 04:02 AM

    @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 @ 5 Feb 2010 04:38 AM

    @Przemek: Good luck.

    @ admin for ur test cases my

    maximus1988 @ 5 Feb 2010 12:33 PM

    @ 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

    triplem @ 5 Feb 2010 12:55 PM

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

    big confusion with the

    shrikant169 @ 5 Feb 2010 02:52 PM

    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 @ 5 Feb 2010 03:06 PM

    @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 :)

    shrikant169 @ 5 Feb 2010 03:40 PM

    @Brian thanks a lot :)

    How many decimal places

    mbalunovic @ 6 Feb 2010 03:23 PM

    How many decimal places points in input have?

    @ brian   supppose there are

    bhavesh.j25 @ 7 Feb 2010 05:21 PM

    @ 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 @ 7 Feb 2010 06:01 PM

    @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

    izulin @ 8 Feb 2010 11:39 PM

    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

    rockaustin2k6 @ 10 Feb 2010 04:15 AM

    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

    thocevar @ 10 Feb 2010 04:59 AM

    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

    rockaustin2k6 @ 10 Feb 2010 05:23 AM

    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

    anant4coding @ 10 Feb 2010 04:44 PM

    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 @ 11 Feb 2010 01:22 PM

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

    SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

    Programming Competition Fetching successful submissions
    Directi Go for Gold
    CodeChef is a global programming communityCodeChef hosts online programming competitions
    CodeChef is a non-commercial competitive programming community
    • About CodeChef
    • About Directi
    • CEO's Corner
    • C-Programming
    • Programming Languages
    • Contact Us
    © 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
    In order to report copyright violations of any kind, send in an email to copyright@codechef.com
    CodeChef a product of Directi
    The time now is:
    CodeChef - A Platform for Aspiring Programmers

    CodeChef was created as a platform to help programmers make it big in the world of computer programming. At CodeChef we work hard to revive the geek in you by hosting programming contests on a monthly basis. We also aim to have training sessions and events related to online programming for programmers around the world. Apart from providing a platform for programming competitions, CodeChef also has various tutorials and forum discussions to help those who are new to the world of computer programming.

    Practice Section - A Place to hone your 'Computer Programming Skills'

    Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our judge accepts solutions in over 35+ programming languages. Online programming was never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming competitions that take place through-out the month on CodeChef.

    Compete - Monthly Programming Contests and Cook-offs

    Here is where you can show off your computer programming skills. Take part in our 10 day long monthly programming contests and the shorter format Cook-off programming contests. Put yourself up for recognition and win great prizes. Prizes worth up to Rs.20,000 and $700 are up for grabs every month along with lots more CodeChef goodies.

    Discuss

    Are you new to computer programming? Do you need help with algorithms? Then be part of CodeChefs Forums and interact with all our programmers love helping out other programmers and share their ideas.

    CodeChef Community

    As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competitions is not the only feature on CodeChef. Be a part of the CodeChef community through CodeChef meetups and techtalks. You can also host a programming contest for your institute on CodeChef and be a guest author on our blog.

    Domain Name Registration, Web hosting, and Website Design provided by BigRock.com