結果
問題 |
No.1610 She Loves Me, She Loves Me Not, ...
|
ユーザー |
|
提出日時 | 2021-10-26 00:10:37 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 2,000 ms |
コード長 | 773 bytes |
コンパイル時間 | 1,878 ms |
コンパイル使用メモリ | 178,704 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-03 23:38:29 |
合計ジャッジ時間 | 3,280 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define ll long long #define rep(i, n) for (int i = 0; i < (n); i++) #define P pair<int, int> set<int> G[5010]; int main() { int n, m; cin >> n >> m; rep(i,m) { int a, b; cin >> a >> b; a--, b--; G[a].insert(b); G[b].insert(a); } queue<int> q; rep(i,n) { if (G[i].size() == 1) q.push(i); } int cnt = 0; while (!q.empty()) { int v = q.front(); q.pop(); if (G[v].size() == 1) { cnt++; for (int nv : G[v]) { G[nv].erase(v); if (G[nv].size() == 1) q.push(nv); } G[v].clear(); } //cout << v << " " << deg[v] << " " << nv << " " << deg[nv] << endl; } if (cnt%2) cout << "Yes" << endl; else cout << "No" << endl; }