# Marathon Match 74 - Marathon Match 74

## Key Information

Register
Submit
The challenge is finished.

## Challenge Overview

### Problem Statement

Warning: This problem statement contains subscripts and superscripts that may not display properly if viewed from outside the arena or TopCoder web site.

The Traveling Salesperson Problem (TSP) is an old and well-known problem (http://en.wikipedia.org/Traveling_salesman_problem). Here we will call the places to visit "locations" rather than "cities." We consider the two-dimensional Euclidean version of the TSP, where you are given the coordinates of each location and the traveling cost between locations is defined to be the two-dimensional Euclidean distance between the two locations, ( (x1-x2)2 + (y1-y2)2 )1/2.

The nearest-neighbor heuristic (NN) is a simple technique for finding an approximate solution to the TSP. Given a starting location, the NN-traveler always visits the nearest unvisited location next. Pseudocode for NN is shown below:

```
currentLocation = initialLocation
visited[currentLocation] = true
tourLength = 0
while ( count(unvisited) > 0 ) {
nextLocation = unvisitedNearestTo(currentLocation)
tourLength += distance(currentLocation, nextLocation)
currentLocation = nextLocation
visited[currentLocation] = true
}
tourLength += distance(currentLocation, initialLocation)

```

In this problem, your goal is to select a set of locations (in a square) such that the tour produced by NN is as long as possible. You must start your NN tour at a given initial location and your NN tour must visit some other fixed locations and some additional locations. The initial location and the other fixed locations will be passed to your method in the int[]s X and Y. The initial location will be encoded as (X, Y). The other fixed locations will be encoded in (X[i], Y[i]) for i >= 1. The int N will contain the number of additional locations you will place. If Nf is the number of elements in X (or Y), then Nf + N is the total number locations that will be in the NN tour (one fixed initial location, Nf - 1 other fixed locations and N additional locations that you will return).

Your method, placeLocations, given the parameters described above (N, X, Y), should return a value of int[] which contains the coordinates of your N additional locations. Your return must contain N*2 elements and each element will be an int between 0 and 1,000,000,000, inclusive. The element values in your return will be ordered (x0, y0, x1, y1, ��� xN-1, yN-1).

Your raw score for each test case will be the length of the NN tour divided by 1,000,000,000. If your return does not contain N*2 elements or if any of the elements is not between 0 and 1,000,000,000, inclusive, then your raw (and final) score for that test case will be zero. Your final score for each provisional and final test case will be (your/best)4, where your is your raw score for this test case, best is the highest raw score of all competitors for this test case and the ratio is raised to the fourth power.

### Definition

 Class: AntiTravelingSalesperson Method: placeLocations Parameters: int, int[], int[] Returns: int[] Method signature: int[] placeLocations(int N, int[] X, int[] Y) (be sure your method is public)

### Notes

-The time limit is 10 seconds per test case.
-The memory limit is 1024 megabytes.
-The source code size limit is 65536 bytes.
-There are 100 provisional test cases.
-A visulalizer/off-line tester is provided.
-Although the initial location (X, Y) must be the first location in the NN tour, the other fixed locations and the additional locations that you return can be visited in any order.
-NN Tie Breaker: If there is more than one nearest unvisited location at some step then the earlist (lowest index) candidate in your return is chosen to be visited. If none of your returned locations is a candidate, then the lowest indexed candidate of the fixed points is chosen. The order of the locations in your return is only significant when a tie exists.

### Constraints

-N will be between 10 and 10,000, inclusive.
-N will be chosen by N = round(10x), where x is a random floating point number (chosen from a uniform distibution) between 1.0 and 4.0, inclusive (except that the first four examples, with seeds 1, 2, 3 and 4, are hardwired to give N = 10, 100, 1000 and 10000).
-X and Y will contain between 3 and min(10,N/3) elements, inclusive.
-The number of elements in X and Y will be chosen randomly from a uniform distribution.
-X and Y will contain the same number of elements.
-Each element of X and Y and will be between 0 and 1,000,000,000 inclusive.
-Each element of X and Y will be chosen randomly from a uniform distribution.

### Examples

0)

 `"1"`
```Returns:
"N = 10
point 0 = (854833494, 716213306)
point 1 = (277032011, 807202676)
point 2 = (430818430, 844549427)"```
1)

 `"2"`
```Returns:
"N = 100
point 0 = (87233015, 187640191)
point 1 = (733134899, 885494843)
point 2 = (238743005, 755723728)"```
2)

 `"3"`
```Returns:
"N = 1000
point 0 = (750283517, 178242579)
point 1 = (313265053, 786252401)
point 2 = (786588581, 650518220)"```
3)

 `"4"`
```Returns:
"N = 10000
point 0 = (612302661, 257655917)
point 1 = (381751710, 429791965)
point 2 = (344074056, 795050248)
point 3 = (148029080, 545033106)"```
4)

 `"5"`
```Returns:
"N = 200
point 0 = (711727651, 215075349)
point 1 = (459457681, 699422879)
point 2 = (965822539, 967261696)"```
5)

 `"6"`
```Returns:
"N = 8931
point 0 = (128782045, 716595407)
point 1 = (452512485, 970382194)
point 2 = (715635511, 393473916)
point 3 = (859941041, 956096100)
point 4 = (409217697, 86896632)
point 5 = (23117212, 254435645)
point 6 = (344630154, 546324593)"```
6)

 `"7"`
```Returns:
"N = 123
point 0 = (29327845, 192575209)
point 1 = (802625069, 460822279)
point 2 = (259910575, 527467580)
point 3 = (926788889, 45838702)
point 4 = (333728888, 18651975)"```
7)

 `"8"`
```Returns:
"N = 170
point 0 = (682917127, 447661903)
point 1 = (117503582, 377768314)
point 2 = (50680117, 641869)
point 3 = (516808123, 127944713)
point 4 = (921458613, 887714611)
point 5 = (883919556, 2296448)
point 6 = (94543644, 167142444)"```
8)

 `"9"`
```Returns:
"N = 1070
point 0 = (626905271, 908880520)
point 1 = (414050868, 522049239)
point 2 = (634924536, 215791625)
point 3 = (266025891, 247006561)
point 4 = (213107441, 875959733)
point 5 = (221800893, 559667121)
point 6 = (571361335, 84624842)
point 7 = (366277786, 348345757)
point 8 = (510965748, 682484909)"```
9)

 `"10"`
```Returns:
"N = 66
point 0 = (771179920, 831483078)
point 1 = (405668628, 801499559)
point 2 = (263568982, 114740778)"```

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2020, TopCoder, Inc. All rights reserved.

## LEARN:

Topcoder Challenges Explained