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
    • All Contests
    • June Long 2012
    • May Cook-Off
    • May Long 2012
  • DISCUSS
    • Forums
    • Blog
    • Wiki
    • Facebook
    • 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
    • Tutorials
    • Long Contest Ranks
    • Short Contest Ranks
    • Event Calendar
  • 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


Author: admin
Date Added: 15-12-2009
Time Limit: 1 - 10 sec
Source Limit: 50000 Bytes
Languages: ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TEXT, WSPC


  • 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 algorithms, computer programming and programming contests. At CodeChef we work hard to revive the geek in you by hosting a programming contest at the start of the month and another smaller programming challenge in the middle of the month. We also aim to have training sessions and discussions related to algorithms, binary search, technicalities like array size and the likes. Apart from providing a platform for programming competitions, CodeChef also has various algorithm 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 programming contest judge accepts solutions in over 35+ programming languages. Preparing for coding contests were 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 challenges 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 coding contest and the shorter format Cook-off coding contest. Put yourself up for recognition and win great prizes. Our programming contests have prizes worth up to Rs.20,000 and $700lots more CodeChef goodies up for grabs.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be a part of CodeChef's Forums and interact with all our programmers - they love helping out other programmers and sharing their ideas. Have discussions around binary search, array size, branch-and-bound, Dijkstra's algorithm, Encryption algorithm and more by visiting the CodeChef Forums and Wiki section.

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. You can also host a coding contest for your institute on CodeChef, organize an algorithm event and be a guest author on our blog.

Go For Gold

The Go for Gold Initiative was launched about a year after CodeChef was incepted, to help prepare Indian students for the ACM ICPC World Finals competition. In the run up to the ACM ICPC competition, the Go for Gold initiative uses CodeChef as a platform to train students for the ACM ICPC competition via multiple warm up contests. As an added incentive the Go for Gold initiative is also offering over Rs.8 lacs to the Indian team that beats the 29th position at the ACM ICPC world finals. Find out more about the Go for Gold and the ACM ICPC competition here.

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