結果

問題 No.408 五輪ピック
ユーザー nebukuro09nebukuro09
提出日時 2017-06-10 12:13:39
言語 D
(dmd 2.107.1)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,318 bytes
コンパイル時間 878 ms
コンパイル使用メモリ 101,188 KB
実行使用メモリ 14,184 KB
最終ジャッジ日時 2023-09-03 14:12:13
合計ジャッジ時間 10,539 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
12,164 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 100 ms
11,016 KB
testcase_06 AC 28 ms
4,448 KB
testcase_07 AC 44 ms
8,376 KB
testcase_08 AC 43 ms
7,264 KB
testcase_09 AC 40 ms
8,204 KB
testcase_10 AC 29 ms
4,440 KB
testcase_11 AC 27 ms
4,380 KB
testcase_12 AC 51 ms
9,300 KB
testcase_13 AC 79 ms
11,072 KB
testcase_14 AC 11 ms
4,384 KB
testcase_15 AC 245 ms
11,076 KB
testcase_16 AC 72 ms
11,020 KB
testcase_17 AC 59 ms
9,836 KB
testcase_18 AC 58 ms
10,496 KB
testcase_19 AC 60 ms
9,788 KB
testcase_20 AC 14 ms
4,380 KB
testcase_21 AC 9 ms
4,384 KB
testcase_22 AC 25 ms
4,384 KB
testcase_23 AC 102 ms
11,608 KB
testcase_24 AC 54 ms
10,100 KB
testcase_25 AC 213 ms
14,184 KB
testcase_26 AC 62 ms
11,080 KB
testcase_27 AC 247 ms
12,660 KB
testcase_28 TLE -
testcase_29 TLE -
testcase_30 AC 2 ms
4,384 KB
testcase_31 AC 1 ms
8,772 KB
権限があれば一括ダウンロードができます

ソースコード

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, core.stdc.stdio;

immutable int INF = 1 << 28;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto edges = new int[][](N);
    foreach (i; 0..M) {
        s = readln.split.map!(to!int);
        edges[s[0] - 1] ~= s[1] - 1;
        edges[s[1] - 1] ~= s[0] - 1;
    }


    auto VU = new bool[int][](N);

    foreach (u; edges[0]) {
        foreach (v; edges[u]) {
            if (v != 0)
                VU[v][u] = true;
        }
    }


    bool ok = false;
    
    foreach (i; 1..N) {
        foreach (j; edges[i]) {
            if (j < i) continue;
            bool ij, ji;
            if (j in VU[i]) VU[i].remove(j), ij = true;
            if (i in VU[j]) VU[j].remove(i), ji = true;
            
            auto il = VU[i].keys.length;
            auto jl = VU[j].keys.length;

            if (il == 1 && jl == 1 && VU[i].keys[0] != VU[j].keys[0])
                ok = true;
            if (il > 0 && jl > 0 && max(il, jl) > 1)
                ok = true;

            if (ij) VU[i][j] = true;
            if (ji) VU[j][i] = true;
        }
    }

    writeln(ok ? "YES" : "NO");
}
0