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 Challenge 2013
    • May Cook-Off 2013
    • May Challenge 2013
  • DISCUSS
    • Forums
    • Blog
    • Wiki
    • Facebook
    • Twitter
  • COMMUNITY
    • Campus Chapters
    • Host your Contest
    • Go for Gold
    • All Educational Initiatives
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Tutorials
    • Long Contest Ranks
    • Short Contest Ranks
    • Event Calendar
    • Top Contributors on Discuss
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Compete » December 2009 (Contest XI) » Effective Sets

Effective Sets

Problem code: J4

  • All Submissions

All submissions for this problem are available.

Johnny has been hired to write a program to analyse strategic data for the Bytelandian Navy. His task is described below.

There are N battleships represented as N points on the plane. The radius of a ship is defined to be the distance from that ship to the ship closest to it. The effective set for a ship is defined to be the set of all ships (excluding itself) which are at a distance from that ship of no more than twice its radius. The number of elements in the effective set of a ship is called the effective value of that ship.

Johnny needs to write a program to calculate the radius and the effective value of each battleship. This task is so tough that without your help, Johnny could never finish it. Let's help him!

Input

The first line contains t, the number of test cases (about 5). Then t test cases follow. Each test case has the following form:

  • The first line contains an integer N, the number of battleships (1 <= N <= 30000).
  • Each line in the next N lines contains two integers X, Y (0 <= X, Y <= 10000) represents the coordinates of a battleship.

Each test case's input is separated by a blank line. There may be more than one ships located at the same place.

Output

For each test case, print N lines. Each line should contain two numbers which are the radius and the effective value of the corresponding battleship. The radius should be rounded to 2 decimal points.

Print a blank line after each test case's output.

Example

Input
2

3
0 0
0 0
3 4

5
5 3
7 8
0 9
3 1
4 4

Output
0.00 1
0.00 1
5.00 2

1.41 2
5.00 4
6.40 4
2.83 2
1.41 1

Author: admin
Date Added: 15-10-2009
Time Limit: 1 - 2 sec
Source Limit: 50000 Bytes
Languages: ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CS2, D, FORT, FS, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, 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.

The problem statement says

xhae @ 1 Dec 2009 03:03 PM

The problem statement says "There may be more than one ships located at the same place", but I think in Example 1, there are two ships in (0,0). Am I right?

.....Woops I misunderstand

xhae @ 1 Dec 2009 03:03 PM

.....Woops I misunderstand the statement. Sorry.

In the first sample test,

gamabunta @ 1 Dec 2009 04:58 PM

In the first sample test, shouldn't the distance be 5 (its given 5.10)? or maybe even 0 for the ship located at 0,0 has its logically closest ship at 0,0

i think that for the first

ab_batra @ 1 Dec 2009 05:07 PM

i think that for the first test case the output must be

0 1

0 1

5 2

I also think the sample

akuegel @ 1 Dec 2009 06:23 PM

I also think the sample output is wrong. It should be

0.00 1
0.00 1
5.00 2

1.41 2
5.00 4
6.40 4
2.83 2
1.41 1

For example, for the second sample test case and the first point, the effective value is two because the closest point to (5, 3) is (4, 4) at distance sqrt(2), and (3,1) has distance 2 * sqrt(2) which is no more than twice the radius.

It's definitely something

frost_nova @ 1 Dec 2009 07:05 PM

It's definitely something wrong with test cases, because even naive approach gets WA.

Admins check the test data, please.

We are looking into this.

admin @ 1 Dec 2009 07:08 PM

We are looking into this.

do we have to read a blank

balajir1990 @ 2 Dec 2009 12:36 AM

do we have to read a blank line after number of test cases as shown in example

and why C#2 not supported Its not telling any reason

Its quite strange that you

akhil89 @ 2 Dec 2009 01:03 AM

Its quite strange that you are still "looking into it" :P

So whats the correct output

Saurabh Singh @ 2 Dec 2009 07:19 AM

So whats the correct output then . How can output be 5.10 in first case ?

My problems with codechef so far :-

1) forgets my password.

2) Stuck at 26.2XXXXX in other problem.

3) Don't know output of this problem.

4) Usually loading of pages from site is slow.

But doesn't matter i suggest all this for improvement . You guys are doing a great job. Its a great initiative.

2AC so far. Is sample I/O

white_king @ 2 Dec 2009 11:13 AM
2AC so far. Is sample I/O wrong, but judge I/O correct? Though, Yarets claimed that his neive approach got WA. So confusing, i hope Chefs are looking into this.

2AC so far. Is sample I/O

white_king @ 2 Dec 2009 11:13 AM
2AC so far. Is sample I/O wrong, but judge I/O correct? Though, Yarets claimed that his neive approach got WA. So confusing, i hope Chefs are looking into this.

I think the test cases are

balakrishnan_v @ 2 Dec 2009 11:46 AM

I think the test cases are correct and they concur with the problem statement.

The correct output for the examples is that given by Adrian Kuegel.

I dont know why but I am

akhil89 @ 2 Dec 2009 12:45 PM

I dont know why but I am getting SIGABRT runtime error on submitting my code for this problem.

Can some one plz suggest why I might be getting it.

There is nothing in the help section as well.

Hi... The radius of a ship is

prateek @ 2 Dec 2009 01:42 PM

Hi...

The radius of a ship is defined to be the distance from that ship to the ship closest to it.

So if the two ship are at same point, the distance has to be zero.

Please do the correction in the test cases.

Thanks

The sample I/O for this

admin @ 2 Dec 2009 04:41 PM

The sample I/O for this problem has been fixed.

How can i take test

sitaramkola @ 2 Dec 2009 06:25 PM

How can i take test case?

randomly.....

suggest me a way

I have two classes... how do

aldrine.einsteen @ 3 Dec 2009 09:43 AM

I have two classes... how do i upload or execute?

Kola: I came close to getting

jcomeau_ictx @ 3 Dec 2009 12:05 PM

Kola: I came close to getting disqualified last time I made such suggestions during a contest.

Aldrine: I believe you can package in a jarfile. The specs for it are somewhere here on the site. Sorry to be so vague, but I haven't had to do it yet myself.

what should be the answer for

sesha_giri_nit @ 3 Dec 2009 07:55 PM

what should be the answer for a case like

1(N)

1 2

as 1<=N<=30000

What should be the answer for

akhil89 @ 4 Dec 2009 01:53 AM

What should be the answer for n=1?

Admins please specify this.

What needs to be the output in case of infinity?

It took me 6 wrong

akhil89 @ 4 Dec 2009 02:54 AM

It took me 6 wrong submissions and over an hour to figure out what does codechef want for the trivial case of n=1.

I sincerely believe that it should be mentioned in the problem statement or at least admins should have replied to Giri's post a day ago. Admins here seem to be neglecting a lot comments which sincerely should be answered

 

it must be zero ...... as

gurpreet_09 @ 4 Dec 2009 03:01 PM

it must be zero ......

as except itself no other ship is present........

hence o/p must be 0.00 0

correct me if i m wrong..................

@core2duo The problem

admin @ 4 Dec 2009 03:12 PM

@core2duo The problem statement is clear enough to address your questions. There is only one way to interpret the statement.

administrator , due to the

Deepika Bhansali @ 5 Dec 2009 02:10 AM

administrator , due to the use of sqrt function the command gets executed with the command gcc <filename>.c -lm

but if you execute the file with command gcc <filename>.c only and not use -lm then the runtime error occurs so please tell me what should I do...

@Aniruddha The problem

triplem @ 5 Dec 2009 02:44 AM

@Aniruddha The problem statement does not mention what to print in the case of N=1 at all. It says to print out the distance from each ship to the nearest ship; that distance is undefined. It is most definitely not 0, which implies there is a second ship at exactly the same location.

The problem statement needs to be fixed.

Luckily i might have hit the

rajatag12 @ 5 Dec 2009 06:26 AM

Luckily i might have hit the correct return for such case (N=1). because my solution has been accepted and i didn't take particular care of the case where N would be 1. Though i too think, that either the constraints should be 2<=N<=30000, or answer for N=1 should be mentioned clearly.

if i don't take any special

abhayjit @ 6 Dec 2009 02:04 AM

if i don't take any special case for n=1 in my program and take an input with n=1 i get a run time error on my pc . but the chef shows wrong answer . does tht mean mean tht n=1 is not the part of input ?? any one with successful submission for this problem submit a code where ur program produces run time error for n=1 (like divide by 0) and plz check ??

if not wht has to be the output for n=1??

Whats the intent ? Disqualify

rajatag12 @ 6 Dec 2009 11:01 AM

Whats the intent ? Disqualify someone with correct submision or yourself.. (kidding about intent, but consequences will be these.)

So, what is the answer when N

fushar @ 7 Dec 2009 08:38 PM

So, what is the answer when N = 1? Am I wrong if I ask this? It's very confusing as the answer when N = 1 can't be determined only by reading the problem statement.

No, you aren't wrong to ask;

triplem @ 9 Dec 2009 05:46 AM

No, you aren't wrong to ask; I'm surprised the admin haven't fixed the problem statement yet.

Updated. There is no test

admin @ 9 Dec 2009 05:33 PM

Updated. There is no test case with N = 1.

hey guys i am new to

sharpie @ 9 Dec 2009 06:33 PM

hey guys i am new to codecheff can u give me some tips on how to deal with time limit exceeded???

 

@Admin could you add the data

crazycrackers @ 12 Dec 2009 01:15 AM

@Admin could you add the data set also?

 

I am not sure why did i get WA.

SUCCESSFUL SUBMISSIONS


Fetching successful submissions

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.