結果

問題 No.408 五輪ピック
ユーザー nebukuro09nebukuro09
提出日時 2017-06-10 12:12:21
言語 D
(dmd 2.106.1)
結果
RE  
実行時間 -
コード長 1,297 bytes
コンパイル時間 633 ms
コンパイル使用メモリ 103,176 KB
実行使用メモリ 13,660 KB
最終ジャッジ日時 2023-09-03 14:11:23
合計ジャッジ時間 14,296 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,760 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 AC 1 ms
4,376 KB
testcase_04 RE -
testcase_05 AC 134 ms
11,004 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 383 ms
11,040 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 AC 379 ms
13,660 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 TLE -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

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]) {
            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;
            
            int il = VU[i].keys.length.to!int;
            int jl = VU[i].keys.length.to!int;

            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