結果
問題 | No.1610 She Loves Me, She Loves Me Not, ... |
ユーザー |
|
提出日時 | 2021-07-21 21:31:54 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 9 ms / 2,000 ms |
コード長 | 962 bytes |
コンパイル時間 | 1,832 ms |
コンパイル使用メモリ | 171,504 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-17 16:18:33 |
合計ジャッジ時間 | 2,993 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
// #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define all(x) x.begin(), x.end() #define lch (o << 1) #define rch (o << 1 | 1) typedef double db; typedef long long ll; typedef unsigned int ui; typedef pair<int, int> pint; typedef tuple<int, int, int> tint; const int N = 5000 + 5; const int INF = 0x3f3f3f3f; const ll INF_LL = 0x3f3f3f3f3f3f3f3f; vector<int> a[N]; int main() { ios::sync_with_stdio(0); int n, m; cin >> n >> m; for (int i = 1; i <= m; i++) { int u, v; cin >> u >> v; a[u].push_back(v); a[v].push_back(u); } auto check = [&]() { for (int u = 1; u <= n; u++) { if (a[u].size() == 1) { int v = a[u][0]; for (auto p = a[v].begin(); p != a[v].end(); p++) { if (*p == u) { a[v].erase(p); break; } } a[u].clear(); return 1; } } return 0; }; int cnt = 0; while (check()) cnt++; cout << ((cnt & 1) ? "Yes" : "No") << endl; return 0; }