結果
| 問題 | No.583 鉄道同好会 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-02-21 16:41:15 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,156 bytes |
| 記録 | |
| コンパイル時間 | 794 ms |
| コンパイル使用メモリ | 93,644 KB |
| 実行使用メモリ | 1,485,184 KB |
| 最終ジャッジ日時 | 2026-02-21 16:41:21 |
| 合計ジャッジ時間 | 6,012 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | MLE * 1 -- * 2 |
| other | -- * 16 |
ソースコード
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <set>
using namespace std;
const int N = 510;
int t, n, m, d[N], fa[N];
set<int> p, s;
bool Check() {
int cnt = 0;
for (auto e : p) {
if (d[e] % 2 != 0) {
++cnt;
}
}
if (cnt == 0 || cnt == 2) return true;
else return false;
}
int Find(int x) { return fa[x] ? fa[x] = Find(fa[x]) : x; }
int main() {
// freopen("train.in", "r", stdin);
// freopen("train.out", "w", stdout);
scanf("%d%d", &n, &m);
memset(d, 0, sizeof(d));
p.clear();
s.clear();
for (int i = 1; i <= n; ++i) fa[i] = i;
for (int i = 1, u, v; i <= m; ++i) {
scanf("%d%d", &u, &v);
int fx = Find(u), fy = Find(v);
if (fx != fy) {
fa[fx] = fy;
}
++d[u], ++d[v];
p.insert(u);
p.insert(v);
}
for (int i = 1; i <= n; ++i) fa[i] = Find(i);
for (auto e : p) s.insert(Find(e));
if (s.size() >= 2) {
puts("NO");
return 0;
}
if (!Check()) {
puts("NO");
} else {
puts("YES");
}
return 0;
}