結果

問題 No.519 アイドルユニット
ユーザー nebukuro09nebukuro09
提出日時 2017-05-28 22:09:39
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 1,239 bytes
コンパイル時間 808 ms
コンパイル使用メモリ 113,812 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-03 13:39:29
合計ジャッジ時間 4,727 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
7,220 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 109 ms
4,376 KB
testcase_05 AC 78 ms
4,376 KB
testcase_06 AC 68 ms
4,380 KB
testcase_07 AC 63 ms
4,380 KB
testcase_08 AC 60 ms
4,376 KB
testcase_09 WA -
testcase_10 AC 56 ms
4,380 KB
testcase_11 WA -
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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;
}
0