Champ Is Here
All submissions for this problem are available.
ITS TIME FOR "ROYAL RUMBLE" .
John Cena , 15 time WWE champion is all set for another "Royal Rumble" match.
Royal Rumble will have n wrestlers competing each.John Cena has planned a way out to beat the wrestlers.
To win John Cena would have to pick and carry all wrestlers to the dark room with coordinate location( X(dark room) ,Y(dark room) ).
All wrestlers are located at different coordinate locations.
John Cena initially is located at location ( X(dark room) ,Y(dark room) ).
John Cena in one turn can carry at most 2 wrestlers.
Time taken by John to go from one location to another is equal to squared length of the segment between the points of the wrestlers.
Since John Cena is too busy in preparations , he asked you to find the order of actions, which consumes minimum time.
First line contains coordinates ( X(dark room) , Y(dark room) ).
Next line contains integer n specifying number of wrestlers
excluding Cena.Then next n lines contains coordinate locations of n wrestlers.
All wrestlers have same strength.
Only their coordinate location is the key to the solution .
- "The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows."
- "First line contains coordinates ( X(dark room) , Y(dark room) ).
Next line contains integer n specifying number of wrestlers excluding Cena.
Then next n lines contains coordinate locations of n wrestlers.
Minimum Time for taking all wrestlers to ( X(dark room) , Y(dark room)).
Next line must contain order of wrestlers.
Each object in the input is described by its index number (from 1 to n),
Dark Room's point is described by number 0.
The path should start and end in the Dark Room's point.
If there are several optimal paths, print LEXIOGRAPHICALLY SMALLEST ONE.
- 1 ≤ T ≤ 50
- 1 ≤ n ≤ 24
- All Coordinates do not exceed 100 in absolute value.
All given positions are different.
Input: 1 7 -7 2 3 1 -3 8 Output 490 0 1 2 0
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.