結果
| 問題 | No.1610 She Loves Me, She Loves Me Not, ... | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-06-19 17:44:50 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 6 ms / 2,000 ms | 
| コード長 | 1,136 bytes | 
| コンパイル時間 | 1,916 ms | 
| コンパイル使用メモリ | 174,672 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-07-17 15:11:33 | 
| 合計ジャッジ時間 | 2,816 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 32 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> graph(n);
    vector<int> degree(n);
    for (int i = 0; i < m;i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
        degree[a]++;
        degree[b]++;
    }
    queue<int> que;
    for (int i = 0; i < n;i++) {
        if(degree[i] == 1) {
            que.push(i);
        }
    }
    vector<int> sel(n);
    int cnt = 0;
    while(!que.empty()) {
        int now = que.front();
        que.pop();
        if(degree[now] == 0) {
            continue;
        }
        cnt++;
        sel[now] = true;
        degree[now] = 0;
        for(int adj: graph[now]) {
            if(sel[adj]) {
                continue;
            }
            degree[adj]--;
            if(degree[adj] == 1) {
                que.push(adj);
            }
        }
    }
    if(cnt % 2 == 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}
            
            
            
        