結果
| 問題 | No.583 鉄道同好会 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-02-11 20:45:56 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 10 ms / 2,000 ms |
| コード長 | 567 bytes |
| 記録 | |
| コンパイル時間 | 2,977 ms |
| コンパイル使用メモリ | 246,128 KB |
| 実行使用メモリ | 6,144 KB |
| 最終ジャッジ日時 | 2026-03-30 00:36:38 |
| 合計ジャッジ時間 | 3,784 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/cassert:46,
from /usr/include/atcoder/dsu.hpp:5,
from /usr/include/atcoder/dsu:1,
from /usr/include/atcoder/all:2,
from main.cpp:2:
In member function 'int atcoder::dsu::size(int)',
inlined from 'int main()' at main.cpp:20:91:
/usr/include/atcoder/dsu.hpp:42:9: warning: 'r' may be used uninitialized [-Wmaybe-uninitialized]
42 | assert(0 <= a && a < _n);
| ^~~~~~
main.cpp: In function 'int main()':
main.cpp:9:15: note: 'r' was declared here
9 | int n, m, r;
| ^
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n, m, r;
cin >> n >> m;
vector<int> cnt(n);
atcoder::dsu uf(n);
for(int i = 0; i < m; i++){
int u, v;
cin >> u >> v;
r = u;
uf.merge(u, v);
cnt[u]++, cnt[v]++;
}
cout << (count_if(cnt.begin(), cnt.end(), [&](int v){return (v & 1);}) <= 2 && uf.size(r) == count_if(cnt.begin(), cnt.end(), [&](int v){return v >= 1;}) ? "YES" : "NO") << '\n';
}