結果
問題 |
No.1610 She Loves Me, She Loves Me Not, ...
|
ユーザー |
![]() |
提出日時 | 2023-06-11 18:57:52 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 2,000 ms |
コード長 | 1,051 bytes |
コンパイル時間 | 1,283 ms |
コンパイル使用メモリ | 116,380 KB |
最終ジャッジ日時 | 2025-02-14 01:51:35 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
#include <iostream> #include <vector> #include <cmath> #include <map> #include <set> #include <iomanip> #include <queue> #include <algorithm> #include <numeric> #include <deque> #include <complex> #include <cassert> using namespace std; using ll = long long; int main(){ int N, M, a, b, ans=0; cin >> N >> M; vector<vector<pair<int, int>>> E(N); vector<int> deg(N); queue<int> que; vector<bool> ok(M); for (int i=0; i<M; i++){ cin >> a >> b; a--; b--; E[a].push_back({b, i}); E[b].push_back({a, i}); deg[a]++; deg[b]++; } for (int i=0; i<N; i++){ if (deg[i] == 1) que.push(i); } while(!que.empty()){ a = que.front(); que.pop(); deg[a]--; for (auto [x, i] : E[a]){ ok[i] = 1; if (deg[x]){ deg[x]--; if (deg[x] == 1) que.push(x); } } } for (int i=0; i<M; i++) if (ok[i]) ans++; cout << (ans % 2 == 1 ? "Yes" : "No") << endl; return 0; }