結果
問題 |
No.519 アイドルユニット
|
ユーザー |
|
提出日時 | 2017-05-28 22:18:51 |
言語 | D (dmd 2.109.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,225 bytes |
コンパイル時間 | 927 ms |
コンパイル使用メモリ | 123,164 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-12 19:29:09 |
合計ジャッジ時間 | 10,901 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 9 WA * 25 |
ソースコード
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..5*10^^6) { int x, y; do { x = uniform(0, N); y = uniform(0, N); } while (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; }