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 » January 2010 (Contest XII) » Place the balloon

Place the balloon

Problem code: L5

  • All Submissions

All submissions for this problem are available.

Given a set of points on a plane, find the largest possible disc which does not "cover" any of these points (i.e., they can lie on the boundary of the disc, but not inside it) and which is constrained by this set of points (i.e., the disc cannot be moved to infinity along a continuous trajectory).

Input

Input will be consist of several test cases. First will be given 1 <= t <= 20, then number of testcases. Then t testcases follow. Each testcase is of following form. First, 1 <= n <= 50000, the number of points. The following n lines define the points; the i-th line contains two integers: -10000 <= xi,yi <= 10000

.

Output

Output exactly one value: the radius of largest possible disc satisfying the given property. If there is no such disc, output the value -1. Answers should be exact up to 10-6

Example

Input:
2
3
0 1
-1 -1
1 -1
4
0 1
-1-1
1 -1
0 0

Output:
1.25
-1


Date: 2009-12-15
Time limit: 10

s
Source limit: 50000
Languages: C C99 strict C++ 4.0.0-8 C++ 4.3.2 PAS gpc PAS fpc JAVA NICE JAR C# C#2 NEM ST ASM D FORT ADA BASH PERL PYTH RUBY LUA ICON PIKE PHP SCM guile SCM qobi LISP sbcl LISP clisp SCALA HASK ERL CAML CLPS PRLG WSPC BF ICK TEXT JS


  • Submit

Comments

  • Login or Register to post a comment.

I'm unclear as to why, in

jcomeau_ictx @ 2 Jan 2010 08:28 PM

I'm unclear as to why, in case 2, the disc with diameter sqrt(2)/2 directly beneath (0,0) doesn't qualify. It is constrained by the set of points and touches none of them.

I don't know what circle with

triplem @ 3 Jan 2010 02:35 AM

I don't know what circle with sqrt(2)/2 you are imagining. I agree with the sample output.

  I was wrong about the

jcomeau_ictx @ 3 Jan 2010 07:13 AM

diagram of circle for case 2

 

I was wrong about the diameter; it can be a full 1.0 in diameter and still be bounded by the convex hull of the points.

That isn't constrained. It

triplem @ 3 Jan 2010 07:19 AM

That isn't constrained. It can move directly downwards.

ahh... I see now. thank you

jcomeau_ictx @ 3 Jan 2010 07:48 AM

ahh... I see now. thank you again.

Can you please double check

triplem @ 4 Jan 2010 11:37 AM

Can you please double check the test cases for this problem. My brute force checker agrees with my solution on every large test case I have tried, as well as random and hand-chosen small ones. (And submitting the brute force program passes at least the first input file).

Ok, will check this.

admin @ 4 Jan 2010 03:53 PM

Ok, will check this.

Are threads allowed? If so,

seda @ 4 Jan 2010 07:25 PM

Are threads allowed?

If so, would you (the system) sum up their time or determine the time of the main thread of the process only???

 

Have the test cases been

triplem @ 5 Jan 2010 11:41 AM

Have the test cases been checked? (Just wasn't sure as the other problem was fixed without any mention of it).

Well, instead of checking

izulin @ 5 Jan 2010 10:25 PM

Well, instead of checking data-test (which is pointless), I checked your solutions.

Think again. :]

I'm afraid I'm pretty

triplem @ 6 Jan 2010 06:26 AM

I'm afraid I'm pretty convinced. Perhaps you could try comparing Ashutosh's solution to mine, as from the looks of it he may be experiencing the same problem.

Stephen and Ashutosh can't be

balakrishnan_v @ 6 Jan 2010 07:20 AM

Stephen and Ashutosh can't be wrong at the same time ;)

Might I ask how floating

pieguy @ 6 Jan 2010 03:28 PM

Might I ask how floating point accuracy is checked?  Basically, which of the following would the following be acceptable output for the first sample input?

1.25

1.250000

1.2500011 (within 10-6 relative error, but not 10-6 absolute error)

1.2500001

rejudge in progress.. some

izulin @ 6 Jan 2010 05:30 PM

rejudge in progress.. some explanations later

for those who cudnt make out

codegeek @ 6 Jan 2010 08:01 PM

for those who cudnt make out the problem>>

consider a ground with poles dug all over. find the radius of the fattest man who can stand in this ground :P

Well, at least I now know I

triplem @ 7 Jan 2010 05:39 AM

Well, at least I now know I wasn't going crazy :) (The scoreboard doesn't seem to be updating with the rejudge by the way.)

Well, I wouldn't doubt in my

izulin @ 7 Jan 2010 01:16 PM

Well, I wouldn't doubt in my solution, but I found results are nondeterministic (!).

And bug was in totally easy part of the code - finding maximum in sequence of integers (!).

@Mark Greve, @pieguy. Could

admin @ 7 Jan 2010 04:32 PM

@Mark Greve, @pieguy. Could you two please submit your accepted solutions again ?

I think everyone who manages

ashutoshmehra @ 9 Jan 2010 01:52 AM

I think everyone who manages to crack this nut should be awarded a PhD!

No, not really...

izulin @ 9 Jan 2010 11:29 PM

No, not really...

;-)

ashutoshmehra @ 10 Jan 2010 06:01 PM

;-)

Hats off to all those who

balakrishnan_v @ 12 Jan 2010 10:54 AM

Hats off to all those who cracked this nut!!

-1.000000 is acceptable ?

rockaustin2k6 @ 14 Jan 2010 12:49 AM

-1.000000 is acceptable ?

@Balakrishnan - Now you're

innocentboy @ 14 Jan 2010 01:46 AM

@Balakrishnan - Now you're one of us :D

Now that the contest is

rockaustin2k6 @ 15 Jan 2010 03:15 PM

Now that the contest is over.... Can any one comment on the solution ??

I feel that finding circumcircle of all triangles obtained by delaunay triangulation

(consider only those circle which have points cover more than half of circumference)

and maximising the radius.

 

Is it correct ?

Yup.

triplem @ 15 Jan 2010 03:18 PM

Yup.

@Tasnim - be careful with

innocentboy @ 15 Jan 2010 03:24 PM

@Tasnim - be careful with cases like

4

0 0

0 1

1 1

1 0

 

There is a valid answer ( center at .5, .5 ). Your solution might not give that.

@Ajay : My program returns

rockaustin2k6 @ 15 Jan 2010 03:39 PM

@Ajay : My program returns 0.7071068 ..  which is correct ?? Any other cases

@Ajay : My program returns

rockaustin2k6 @ 15 Jan 2010 03:40 PM

@Ajay : My program returns 0.7071068 ..  which is correct ?? Any other cases

Not really :). I mentioned

innocentboy @ 15 Jan 2010 03:44 PM

Not really :). I mentioned this case only because when you consider each circumcircle, if you just consider only the vertices of that triangle, it would fail for this case. If you find all the points which are closest to the circum center [ a total of 4 points in this case ], then it would work.

admins I would like to know

rockaustin2k6 @ 15 Jan 2010 03:52 PM

admins I would like to know the test case which my program fails (submission id 168306) ?Is it the floating point error or still logical error somewhere ?

@Tasnim: I ran your code and

jdmetz @ 16 Jan 2010 03:29 AM

@Tasnim: I ran your code and found some small cases it gives a different answer from mine:

 

2

5

6141 6311

-6233 -3082

4780 -1120

6663 8059

-6259 -3835

5

-1991 -378

9308 -8197

-3569 -6048

8397 7872

-9460 -833

 

My result:

-1

8408.86046237473

 

Your result:

8291.7256079

17516.9305787

i used n^2 delauny

white_king @ 16 Jan 2010 12:37 PM

i used n^2 delauny triangulation. what about others? any one did nlgn?

I did the incremental flip

jdmetz @ 16 Jan 2010 10:58 PM

I did the incremental flip algorithm with random order insertion of vertices which Wikipedia says is O(n log n).  The code is pretty ugly, though.

I did O(n*log(n)). I used the

balakrishnan_v @ 17 Jan 2010 12:43 AM

I did O(n*log(n)).

I used the algorithm mentioned in here:

http://www.geom.uiuc.edu/~samuelp/del_project.html

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