結果
問題 | No.1610 She Loves Me, She Loves Me Not, ... |
ユーザー |
|
提出日時 | 2021-07-21 22:13:42 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 705 bytes |
コンパイル時間 | 1,285 ms |
コンパイル使用メモリ | 125,824 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-17 18:59:30 |
合計ジャッジ時間 | 2,359 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
#include<iostream> #include<queue> #include<vector> using namespace std; const int N = 5e3 + 5; vector<vector<int>>graph(N); int deg[N], n, u, v, m; bool vis[N]; int topo() { queue<int>q; int cnt = 0; for (int i = 1; i <= n; ++i) if (deg[i] == 1) { q.push(i); } while (!q.empty()) { u = q.front(); q.pop(); vis[u] = true; for (auto g : graph[u]) { if (vis[g]) continue; if (--deg[g] == 1) q.push(g); ++cnt; } } return cnt; } int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= m; ++i) { scanf("%d%d", &u, &v); graph[u].push_back(v); graph[v].push_back(u); deg[u]++; deg[v]++; } int res = topo(); if (res & 1) puts("Yes"); else puts("No"); return 0; }