結果
| 問題 |
No.1610 She Loves Me, She Loves Me Not, ...
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-06-23 14:16:11 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,652 bytes |
| コンパイル時間 | 1,848 ms |
| コンパイル使用メモリ | 182,316 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-17 15:42:45 |
| 合計ジャッジ時間 | 3,390 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 RE * 2 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
assert(1 <= n && n <= 5000);
assert(1 <= m && m <= 5000);
vector<vector<int>> graph(n);
vector<int> degree(n);
int cnt_input = 0;
int a, b;
set<pair<int, int>> st;
while(cin >> a) {
if(cin >> b) {
assert(1 <= a && a <= n);
assert(1 <= b && b <= n);
assert(a != b);
if(a > b) {
swap(a, b);
}
assert(st.find(make_pair(a, b)) == st.end());
st.insert(make_pair(a, b));
cnt_input++;
a--;
b--;
graph[a].push_back(b);
graph[b].push_back(a);
degree[a]++;
degree[b]++;
}
}
assert(cnt_input == m);
queue<int> que;
vector<int> sel(n);
for (int i = 0; i < n;i++) {
if(degree[i] == 1) {
sel[i] = true;
que.push(i);
}
}
int cnt = 0;
while(!que.empty()) {
int now = que.front();
que.pop();
if(degree[now] == 0) {
continue;
}
cnt++;
degree[now] = 0;
for(int adj: graph[now]) {
if(degree[adj] == 0) {
continue;
}
degree[adj]--;
if(degree[adj] == 1) {
sel[adj] = true;
que.push(adj);
}
}
}
if(cnt % 2 == 1) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
return 0;
}