結果
| 問題 |
No.519 アイドルユニット
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-05-28 22:09:39 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,239 bytes |
| コンパイル時間 | 752 ms |
| コンパイル使用メモリ | 122,772 KB |
| 実行使用メモリ | 13,760 KB |
| 最終ジャッジ日時 | 2024-06-12 19:28:54 |
| 合計ジャッジ時間 | 4,112 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 5 WA * 7 TLE * 1 -- * 21 |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;
void main() {
auto N = readln.chomp.to!int;
auto A = N.iota.map!(_ => readln.split.map!(to!int).array).array;
auto used = new bool[](N);
auto tied = new int[](N);
int point = 0;
foreach (i; 0..N/2) {
int x, y;
do {
x = uniform(0, N);
} while (used[x]);
used[x] = true;
do {
y = uniform(0, N);
} while (used[y]);
used[y] = true;
tied[x] = y;
tied[y] = x;
}
foreach (_; 0..10^^6) {
int x, y;
do {
x = uniform(0, N);
y = uniform(0, N);
} while (x == y || tied[x] == y);
int xx = tied[x];
int yy = tied[y];
if (A[x][xx] + A[y][yy] < A[x][y] + A[xx][yy]) {
tied[x] = y;
tied[y] = x;
tied[xx] = yy;
tied[yy] = xx;
}
}
point = 0;
fill(used, false);
foreach (i; 0..N) {
if (!used[i]) point += A[i][tied[i]];
used[i] = used[tied[i]] = true;
}
point.writeln;
}