You are on page 1of 3

Login Signup Login or

Signup with
Have you tried CodeChefs "Code, Compile & Run" Its pretty cool. Try it out by pressing Ctrl+; and
typing "ide" [X]

PRACTICE COMPETE DISCUSS COMMUNITY HELP ABOUT

Home Practice(easy) Circle of death

Circle of death
ALL SUBMISSIONS SUBMIT
Problem code: CIRKILL
Like Share 15 people like this. Sign Up to see what your
friends like.

All submissions for this problem are available. SUCCESSFUL SUBMISSIONS


In the land of Chefton there is a trio of killers known as Team Rocket (TR). Chefton is basically a set of
tiles, only a single person can stand on a tile at a given instance. Each tile can be described by X and Y User Time Mem Lang Solution
co-ordinates describing the position of the tile. For the purpose of this problem, you may assume that a
tile does not have any length of breadth. It is only a point. aanchal204 0.00 2.2M C View
TR kill in a very unique way. Lets say the three members of the trio stand on the tiles T1, T2, T3
respectively. If a unique circle, say C, can be formed using T1, T2, T3 then all the people standing on the p1p2_3 0.00 2.2M C View
tiles lying within or on the circle C will be killed.
Chefton Intelligence Agency (CIA) send their top agent Ash to Chefton. Let us assume that TR and Ash paramsingh96 0.00 2.2M C View
are standing on random tiles, satisfying the following constraints
a_0000_prerna 0.00 2.2M C View
All four individuals, the three members of TR and Ash are on different tiles.
There may be several ways in which the four individuals are placed. You may assume that the three View
codersan 0.00 2.6M C++ 4.3.2
members of TR are indistinguishable, while considering how many ways can everyone be placed. Any
one of these ways now, is equiprobable. For clarity, refer to the explanation section.
sanjeev1779 0.00 2.6M C++ 4.3.2 View
What is the probability that Ash can be killed by Team Rocket.
Input yellow1 0.00 2.6M C++ 4.3.2 View

The first line of the input contains an integer T, the number of test cases. The description of T test cases
allan_android 0.00 2.6M C++ 4.3.2 View
follows. The first line of each test case contains a single integer N, the number of tiles in Chefton. The
next N lines consist of 2 space separated integers each, where the i'th line specifies the X and Y co-
ordinates of the i'th tile. princerk 0.00 2.6M C++ 4.3.2 View

Output View
kaushal67 0.00 2.6M C++ 4.3.2
For each test case, output a single line containing the probability that Team Rocket kills Ash. Your
answer is considered correct if it has an absolute error less than 10-6. ouditchya_713 0.00 2.6M C++ 4.3.2 View

Constraints
bha4347 0.00 2.8M C++ 4.3.2 View
1 T 10
4 N 30
-50 X, Y 50 1 of 7
All (X,Y) in a test case are unique.
Sample
Input HELP
2
4
-1 0
00
01
10
5
-1 0
0 -1
00
01
10
Output
0.25
0.4

Explanation
Test 1: There are 4 ways TR may be placed. Each one of them has the probability 0.25, of occuring.
{ (-1,0), (0,0), (0,1) }, Ash is at (1,0). Ash cannot be killed even though TR has a valid and unique
"kill circle".
{ (-1,0), (0,0), (1,0) }, Ash is at (0,1). Ash cannot be killed because TR does not have a unique "kill
circle".
{ (-1,0), (0,1), (1,0) }, Ash is at (0,0). Ash can be killed since he is standing inside TR's "kill circle".
{ (0,0), (0,1), (1,0) }, Ash is at (-1,0). Ash cannot be killed even though TR has a valid and unique
"kill circle".

converted by W eb2PDFConvert.com
Test 2: There are 10 ways TR may be placed. Each one of them has the probability 0.1, of occuring. For
each one of those placements, Ash may be placed at one of the 2 remaining positions. Thus, with
probability 0.05 each, there are 20 total arrangements to consider. Ash can be killed by TR in 8 of these Program should read from standard input and write to
20 cases. standard output. After you submit a solution you can see
your results by clicking on the [My Submissions] tab on
Author: kaushik_iska the problem page. Below are the possible results:

Tester: gamabunta
Accepted Your program ran successfully and
Editorial http://discuss.codechef.com/problems/CIRKILL gave a correct answer. If there is a score for the
problem, this will be displayed in parenthesis next to
Date Added: 9-06-2013 the checkmark.
Time Limit: 1 sec
Time Limit Exceeded Your program was
Source compiled successfully, but it didn't stop before time
50000 Bytes limit. Try optimizing your approach.
Limit:
ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.3.2, CPP 4.8.1, CPP11, Wrong Answer Your program compiled and ran
Languages: CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAVA, JS, LISP clisp, LISP sbcl, LUA, succesfully but the output did not match the expected
NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH output.
3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC

Runtime Error Your code compiled and ran but


encountered an error. The most common reasons are
using too much memory or dividing by zero. For the
Comments specific error codes see the help section.
Please login at the top to post a comment.
Compilation Error Your code was unable to
compile. When you see this icon, click on it for more
hinu @ 26 Jul 2013 12:48 PM information.
Please help me.I donot know about programing.I just do one time C languages.I really want to do
learn languages If you are still having problems, see a sample solution
here.

the_luc1f3r @ 26 Jul 2013 01:29 PM

@hinu there is a discussion where different links for learning c and c++ has been provide the link is
as below http://discuss.codechef.com/questions/10471/references-for-learning-c hope u learn and
enjoy coding on codechef

vinaylodha24 @ 26 Jul 2013 07:35 PM

can anyone post some more sample cases.??

kokulraam @ 7 Aug 2013 07:30 AM

nice one

codingwizard @ 8 Feb 2014 10:53 PM

what do you mean by a unique kill circle..there will obviously be a unique circle through any 3 non-
collinear points...by that condition does the question mean to say that the 3 points are not collinear

kshitij_anand @ 11 Feb 2014 08:32 PM

@codingwizard :- Yes. Look at the third case of Test 1. The members of TR stand in a straight line.
Since they are in a co-linear arrangement, no "unique" circle can be formed.

sh1oy2sm3 @ 4 Dec 2014 12:21 AM

understanding the story is harder than the coding of this!!!

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 The time now is: 01:22:22 PM
In order to report copyright violations of any kind, send in an email to copyright@codechef.com Your Ip: 184.173.162.50

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+

converted by W eb2PDFConvert.com
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.

converted by W eb2PDFConvert.com

You might also like