Diverta City

AtCoder
IDdiverta2019_2_f
Time3000ms
Memory256MB
Difficulty
Diverta City is a new city consisting of $N$ towns numbered $1, 2, ..., N$. The mayor Ringo is planning to connect every pair of two different towns with a bidirectional road. The length of each road is undecided. A _Hamiltonian path_ is a path that starts at one of the towns and visits each of the other towns exactly once. The reversal of a Hamiltonian path is considered the same as the original Hamiltonian path. There are $N! / 2$ Hamiltonian paths. Ringo wants all these paths to have distinct total lengths (the sum of the lengths of the roads on a path), to make the city diverse. Find one such set of the lengths of the roads, under the following conditions: * The length of each road must be a positive integer. * The maximum total length of a Hamiltonian path must be at most $10^{11}$. ## Constraints * $N$ is a integer between $2$ and $10$ (inclusive). ## Input Input is given from Standard Input in the following format: $N$ [samples]
Samples
Input #1
3
Output #1
0 6 15
6 0 21
15 21 0

There are three Hamiltonian paths. The total lengths of these paths are as follows:

*   $1 → 2 → 3$: The total length is $6 + 21 = 27$.
*   $1 → 3 → 2$: The total length is $15 + 21 = 36$.
*   $2 → 1 → 3$: The total length is $6 + 15 = 21$.

They are distinct, so the objective is met.
Input #2
4
Output #2
0 111 157 193
111 0 224 239
157 224 0 258
193 239 258 0

There are $12$ Hamiltonian paths, with distinct total lengths.
API Response (JSON)
{
  "problem": {
    "name": "Diverta City",
    "description": {
      "content": "Diverta City is a new city consisting of $N$ towns numbered $1, 2, ..., N$. The mayor Ringo is planning to connect every pair of two different towns with a bidirectional road. The length of each road ",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 3000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "diverta2019_2_f"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Diverta City is a new city consisting of $N$ towns numbered $1, 2, ..., N$.\nThe mayor Ringo is planning to connect every pair of two different towns with a bidirectional road. The length of each road ...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments