結果

問題 No.1610 She Loves Me, She Loves Me Not, ...
ユーザー kanra824kanra824
提出日時 2021-06-19 17:52:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 1,046 bytes
コンパイル時間 1,678 ms
コンパイル使用メモリ 175,492 KB
実行使用メモリ 6,732 KB
最終ジャッジ日時 2023-09-24 14:31:01
合計ジャッジ時間 3,116 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 5 ms
6,444 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 24 ms
6,448 KB
testcase_06 AC 24 ms
6,556 KB
testcase_07 AC 24 ms
6,488 KB
testcase_08 AC 23 ms
6,732 KB
testcase_09 AC 24 ms
6,732 KB
testcase_10 AC 23 ms
6,592 KB
testcase_11 AC 24 ms
6,488 KB
testcase_12 AC 22 ms
6,728 KB
testcase_13 AC 23 ms
6,556 KB
testcase_14 AC 1 ms
4,384 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<bool>> g(n, vector<bool>(n));
    vector<int> d(n);
    for (int i = 0; i < m;i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a][b] = true;
        g[b][a] = true;
        d[a]++;
        d[b]++;
    }

    queue<int> que;
    for (int i = 0; i < n;i++) {
        if(d[i] == 1) {
            que.push(i);
        }
    }

    int cnt = 0;
    while(!que.empty()) {
        int now = que.front();
        que.pop();
        if(d[now] == 0) {
            continue;
        }
        cnt++;
        d[now] = 0;
        for (int i = 0; i < n;i++) {
            if(g[now][i] && d[i] != 0) {
                d[i]--;
                if(d[i] == 1) {
                    que.push(i);
                }
            }
        }
    }

    if(cnt % 2 == 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}
0