結果

問題 No.1610 She Loves Me, She Loves Me Not, ...
ユーザー V_Melville
提出日時 2021-07-21 22:12:37
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 695 bytes
コンパイル時間 2,209 ms
コンパイル使用メモリ 199,584 KB
最終ジャッジ日時 2025-01-23 04:23:25
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::vector;
using std::queue;

int main() {
	int n, m;
	cin >> n >> m;
	
	vector<vector<int>> to(n); 
	vector<int> deg(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		to[a].push_back(b);
		to[b].push_back(a);
		deg[a]++;
		deg[b]++;
	}
	
	queue<int> q;
	rep(i, n) if (deg[i] == 1) q.push(i);
	
	int ans = 0;
	while (!q.empty()) {
		int u = q.front();
		if (deg[u] == 0) {
			q.pop();
			continue;
		}
		++ans;
		q.pop();
		for (int v : to[u]) {
			deg[v]--;
			if (deg[v] == 1) 
			   q.push(v);
		}
	}
	
	if (ans % 2 == 1) puts("Yes");
	else puts("No");
	
	return 0;
}
0