TopCoder

User's AC Ratio

100.0% (3/3)

Submission's AC Ratio

100.0% (5/5)

Tags

Description

Given $N \times N$ matrix $a_ {ij}$.
Calculate a permutation $p_ i$ that minimize $\sum_ {i = 0}^ {N - 1} a_ {ip_ i}$.

If there is multiple solutions, print any of them.

Input Format

$N$
$a_ {00}$ $a_ {01}$ ... $a_ {0,{N-1}}$
$a_ {10}$ $a_ {11}$ ... $a_ {1,{N-1}}$
:
$a_ { {N-1}, 0 }$ $a_ { {N-1}, 1 }$ ... $a_ { {N-1}, {N-1} }$

Output Format

$X$
$p_ 0$ $p_ 1$ ... $p_ {N-1}$

$X = \sum_ {i = 0}^ {N - 1} a_ {ip_ i}$

Sample Input 1

3
4 3 5
3 5 9
4 1 4

Sample Output 1

9
2 0 1

Hints

  • $1 \leq N \leq 500$
  • $|a_ {ij}| \leq 10^ {9}$

Note that timelimit is different from https://judge.yosupo.jp/problem/assignment

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 2097152 2097152
1 1000 2097152 2097152
2 1000 2097152 2097152
3 1000 2097152 2097152
4 1000 2097152 2097152
5 1000 2097152 2097152
6 1000 2097152 2097152
7 1000 2097152 2097152
8 1000 2097152 2097152
9 1000 2097152 2097152
10 1000 2097152 2097152
11 1000 2097152 2097152
12 1000 2097152 2097152
13 1000 2097152 2097152