結果

問題 No.408 五輪ピック
ユーザー izuru_matsuuraizuru_matsuura
提出日時 2016-10-18 21:41:32
言語 D
(dmd 2.106.1)
結果
TLE  
実行時間 -
コード長 1,133 bytes
コンパイル時間 693 ms
コンパイル使用メモリ 79,652 KB
実行使用メモリ 9,828 KB
最終ジャッジ日時 2023-09-02 22:24:03
合計ジャッジ時間 7,398 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,368 KB
testcase_01 AC 1 ms
4,372 KB
testcase_02 AC 1 ms
4,372 KB
testcase_03 AC 2 ms
4,368 KB
testcase_04 AC 1 ms
4,372 KB
testcase_05 AC 24 ms
6,364 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;
    scanf("%d %d\n", &N, &M);
    alias E = Tuple!(int, int);
    bool[E] es;
    E[] es1;
    foreach (i; 0 .. M) {
        int a, b;
        scanf("%d %d\n", &a, &b);
        a--; b--;
        if (a > b) swap(a, b);
        es1 ~= E(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; es1) {
        bool a = false, b = false;
        int c = 0;
        for (int i = 1; i < N; i++) {
            if (i == e[0] || i == e[1]) continue;
            if (!f(i, 0)) continue;
            bool flag = false;
            if (f(e[0], i)) {
                a = true;
                flag =true;
            }
            if (f(e[1], i)) {
                b = true;
                flag = true;
            }
            c += flag;
        }
        if (c >= 2 && a && b) {
            writeln("YES");
            return;
        }
    }
    writeln("NO");

}
0