結果

問題 No.2202 贅沢てりたまチキン
ユーザー nono00nono00
提出日時 2023-02-10 01:49:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 350 ms / 2,000 ms
コード長 1,328 bytes
コンパイル時間 2,177 ms
コンパイル使用メモリ 206,916 KB
実行使用メモリ 29,020 KB
最終ジャッジ日時 2023-09-21 07:06:39
合計ジャッジ時間 7,608 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 27 ms
14,000 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 168 ms
26,276 KB
testcase_15 AC 166 ms
26,608 KB
testcase_16 AC 130 ms
28,872 KB
testcase_17 AC 130 ms
29,020 KB
testcase_18 AC 66 ms
15,840 KB
testcase_19 AC 103 ms
26,608 KB
testcase_20 AC 170 ms
26,528 KB
testcase_21 AC 167 ms
26,816 KB
testcase_22 AC 84 ms
8,496 KB
testcase_23 AC 122 ms
8,264 KB
testcase_24 AC 99 ms
9,108 KB
testcase_25 AC 350 ms
25,352 KB
testcase_26 AC 166 ms
26,552 KB
testcase_27 AC 167 ms
26,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define rrep(i, r, l) for (int i = (int)(r); i > (int)(l); i--)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

void solve() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> graph(2 * n, vector<int>());
    rep(i, 0, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b + n);
        graph[b].push_back(a + n);
        graph[a + n].push_back(b);
        graph[b + n].push_back(a);
    }

    vector<int> used(2 * n, -1);
    int now = 0;
    rep(i, 0, 2 * n) {
        if (used[i] != -1) {
            continue;
        }
        used[i] = now;
        queue<int> q;
        q.push(i);
        while (!q.empty()) {
            int u = q.front(); q.pop();
            for (auto v: graph[u]) {
                if (used[v] != -1) {
                    continue;
                }
                used[v] = now;
                q.push(v);
            }
        }
        now++;
    }

    bool flag = true;
    rep(i, 0, n) {
        if (used[i] != used[i + n]) {
            flag = false;
        }
    }

    cout << (flag ? "Yes" : "No") << '\n';
}

int main() {
    int q = 1;
    // cin >> q;
    while (q--) {
        solve();
    }
}
0