結果

問題 No.408 五輪ピック
ユーザー izuru_matsuuraizuru_matsuura
提出日時 2016-10-18 21:36:08
言語 D
(dmd 2.106.1)
結果
TLE  
実行時間 -
コード長 1,032 bytes
コンパイル時間 1,226 ms
コンパイル使用メモリ 140,448 KB
実行使用メモリ 9,404 KB
最終ジャッジ日時 2023-09-02 22:23:30
合計ジャッジ時間 8,080 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,372 KB
testcase_01 AC 2 ms
4,368 KB
testcase_02 AC 1 ms
4,368 KB
testcase_03 AC 1 ms
4,368 KB
testcase_04 AC 2 ms
4,372 KB
testcase_05 AC 55 ms
9,404 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio;
import std.algorithm;
import std.typecons;
import std.string;
import std.array;
import std.conv;
import std.container;

void main() {
    int N, M;
    readf("%d %d\n", &N, &M);
    alias E = Tuple!(int, int);
    bool[E] es;
    auto G = new int[][](N);
    foreach (i; 0 .. M) {
        int a, b;
        readf("%d %d\n", &a, &b);
        a--; b--;
        G[a] ~= b;
        G[b] ~= a;
        if (a > b) swap(a, b);
        es[E(a, b)] = true;
    }

    bool f(int a, int b) {
        if (a > b) swap(a, b);
        return E(a, b) in es ? true : false;
    }

    foreach (e, _; es) {
        bool a = false, b = false;
        int c = 0;
        for (int i = 1; i < N; i++) {
            if (f(e[0], i) && f(i, 0)) {
                a = true;
                c++;
            }
            if (f(e[1], i) && f(i, 0)) {
                b = true;
                c++;
            }
        }
        if (c >= 2 && a && b) {
            writeln("YES");
            return;
        }
    }
    writeln("NO");

}
0