結果
| 問題 | No.1610 She Loves Me, She Loves Me Not, ... | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-10-20 21:53:20 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 8 ms / 2,000 ms | 
| コード長 | 559 bytes | 
| コンパイル時間 | 2,506 ms | 
| コンパイル使用メモリ | 203,252 KB | 
| 最終ジャッジ日時 | 2025-01-25 02:06:41 | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 32 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
int n, m, a, b, t = 0;
set<int> e[5000];
queue<int> Q;
int main()
{
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		a--;
		b--;
		e[a].insert(b);
		e[b].insert(a);
	}
	for (int i = 0; i < n; i++)
		if (e[i].size() == 1)
				Q.push(i);
	while (!Q.empty()) {
		int u = Q.front();
		Q.pop();
		
		if (e[u].size() == 1) {
			int v = *e[u].begin();
			e[v].erase(u);
			t++;
			if (e[v].size() == 1)
				Q.push(v);
		}
	}
	
	if (t & 1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
            
            
            
        