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 » July 2011 Long Contest » Wireless Network

Wireless Network

Problem code: NETWORK

  • All Submissions

All submissions for this problem are available.

A wireless network has been built consisting of many wireless access points for computers. Each access point can support a certain number of computers, and the network will perform better when computers are close to the access points supporting them. Specifically, the greatest distance between any computer and its access point determines the strength of the network. A network has recently been designed that will automatically reconfigure itself every time a computer is added so that the greatest distance will be as small as possible. Your task is to compute, as each computer is added to the network, this distance.

Consider the following example:
There are 2 access points, at (5,5) and (6,9), each of which can support 2 computers. The first computer to be added to the wireless network is at (3,5). This computer connects to the access point at (5,5), which is only a distance of 2 away. The next computer to be added is at (5,2). This computer also connects to the access point at (5,5), and the greatest distance is now 3. A third computer is added at (4,2). This computer cannot connect to the (5,5) access point because it has already reached its limit. But connecting to (6,9) is not a good choice either because its so far away. Instead, the network reassigns the (3,5) computer to the (6,9) access point so that the new computer can connect to the (5,5) access point. The greatest distance is now from the (3,5) computer to the (6,9) access point, which is 5. (Note: in the picture below, the top-left corner is (0,0)).

Input

Input begins with an integer T, the number of test cases to follow. Each test case begins with a line containing 2 integers, S (the number of access points) and C (the number of computers). S+C lines follow. The first S lines contain 3 integers each, giving the coordinates of an access point, followed by the number of connections it can support. The next C lines contain 2 integers each, giving the coordinates of a computer. There is a blank line before each test case.

Output

For each test case, output C lines, where the i'th line contains the greatest distance in the network after the first i computers have been added to the network, rounded to 3 decimal places. Output a blank line after each test case.

Sample Input

3

2 3
5 5 2
6 9 2
3 5
5 2
4 2

2 4
3 6 2
10 9 2
2 5
3 8
4 3
6 4

2 1
10 5 1
6 8 1
3 3

Sample Output

2.000
3.000
5.000

1.414
2.000
7.071
7.071

5.831

Constraints

T is between 1 and 15, inclusive.
S is between 1 and 30, inclusive.
Each access point supports between 1 and 30 connections, inclusive.
C is between 1 and the total number of supported connections, inclusive.
All coordinates comprise integers between 0 and 10000, inclusive.
All coordinates are distinct.


Author: pieguy
Date Added: 11-04-2011
Time Limit: 2 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, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC


  • Submit

Comments

  • Login or Register to post a comment.

Admins, add pleaes Languages

aircube @ 1 Jul 2011 03:54 PM
Admins, add pleaes Languages for this problem, i can`t submit.

@aircube This is fixed

tojochacko @ 1 Jul 2011 04:59 PM
@aircube This is fixed

Hi, May I know if you have

simpleton @ 2 Jul 2011 09:01 PM
Hi, May I know if you have maximum data like this: T = 15 for all testcases S = 30 and C = 900 I think I have an algorithm that tethers on the brink of TLE ... Ok, maybe its well over it =(

to admin: May I know how many

simpleton @ 3 Jul 2011 12:21 PM
to admin: May I know how many seconds do I need to speed up by? My submission ID is 589491.

Agonizing problem, I don't

pr0ton @ 3 Jul 2011 04:04 PM
Agonizing problem, I don't understand why it's so important to spend a lot of time making minor optimisations that don't change complexity.

To pr0ton: I managed to solve

simpleton @ 3 Jul 2011 06:45 PM
To pr0ton: I managed to solve the problem by reducing my complexity :)

@simpleton: So your AC code

coders1122 @ 3 Jul 2011 06:59 PM
@simpleton: So your AC code works in time for a random test case of the limits that you have mentioned in the above comments in your local machine?

@coders1122: Ya. I set

simpleton @ 3 Jul 2011 08:40 PM
@coders1122: Ya. I set maximum constraints and ran a few rounds. Before the speed up, the longest time I took was 2.7 seconds (and this is the code already with a lot of constant optimisations thrown in). After the speed up, it ran for at most 1.5 seconds on the worst testcases I can generate.

Should it be blank line after

senator @ 4 Jul 2011 03:14 PM
Should it be blank line after the last test case? Cause there is no blank line after the last test case in sample output

Is it the comps which are

evanescent @ 4 Jul 2011 08:20 PM
Is it the comps which are equidistant from 2 nodes causing problems? ...hmm

Yes those are test cases for

evanescent @ 4 Jul 2011 08:38 PM
Yes those are test cases for which my code can possibly fail...but what should be the logic to break these ties accurately in advance?

@senator: I can confirm that

coders1122 @ 5 Jul 2011 02:00 AM
@senator: I can confirm that as long as you print every answer in a newline, you should get accepted. Blank line between test cases also seems unnecessary.

Even though I have a solution

coders1122 @ 5 Jul 2011 02:07 AM
Even though I have a solution with good runtime, I dint enjoy optimising the solution for this task. Too hard on optimisation x-( Maybe problem setter wanted to discourage other simple ideas from passing. Nice problem statement though.

Nice problem... though the

flying_ant @ 7 Jul 2011 11:51 AM
Nice problem... though the first idea was correct, didn't expect 'that small thing' was actually enough to get over tle :)

Which small thing ? :P

mkagenius @ 7 Jul 2011 11:55 AM
Which small thing ? :P

inner peace :p

flying_ant @ 7 Jul 2011 11:57 AM
inner peace :p

@flying_ant: Spent hours

pulkit @ 7 Jul 2011 02:46 PM
@flying_ant: Spent hours together optimizing code but finally a small change did the trick... :)

Again, which small change ?

mkagenius @ 7 Jul 2011 04:48 PM
Again, which small change ?

How can solution works 0.6

wRabbits @ 9 Jul 2011 09:30 PM
How can solution works 0.6 sec on max test and get TLE here?

@wRabbits: how you find max

nevidomy @ 9 Jul 2011 11:02 PM
@wRabbits: how you find max test?

@nevidomy: Yeah, agree, it

wRabbits @ 10 Jul 2011 12:03 AM
@nevidomy: Yeah, agree, it might not be the worst. But still...

@wRabbits: my solution works

nevidomy @ 10 Jul 2011 02:49 AM
@wRabbits: my solution works for 0.5 second on random big test but 5 sec for graph where all computers placed near one router and all routers placed randomly

can somebody share your test

dpkmarathe @ 10 Jul 2011 04:24 AM
can somebody share your test cases ? it says all my submissions are wrong.

No, that kind of test is not

wRabbits @ 10 Jul 2011 04:33 AM
No, that kind of test is not the worst for my solution

Again, I can't solve third

pdwd @ 11 Jul 2011 02:48 PM
Again, I can't solve third task...

@pdwd: Dont loose hope, 5

coders1122 @ 11 Jul 2011 02:56 PM
@pdwd: Dont loose hope, 5 mins still remaining. :-)

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