結果
問題 |
No.583 鉄道同好会
|
ユーザー |
![]() |
提出日時 | 2020-04-04 18:33:09 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 29 ms / 2,000 ms |
コード長 | 1,056 bytes |
コンパイル時間 | 2,310 ms |
コンパイル使用メモリ | 199,728 KB |
最終ジャッジ日時 | 2025-01-09 14:06:30 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
#include<bits/stdc++.h> using lint=long long; using lubl=long double; #define ALL(v) std::begin(v),std::end(v) int main(){ std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false); std::cout.setf(std::ios_base::fixed);std::cout.precision(15); lint n,m;std::cin>>n>>m; std::vector<std::vector<lint>>g(n); while(m--){ lint x,y;std::cin>>x>>y; g.at(x).push_back(y); g.at(y).push_back(x); } if(2<std::count_if(ALL(g),[](auto&&v){return v.size()%2==1u;})){ std::cout<<"NO"<<'\n'; return 0; } std::vector<lint>size(n),ckd(n,false),que; for(lint i=0,j=0;i<n;i++){ if(std::exchange(ckd.at(i),true))continue; que.push_back(i); for(;j<(lint)que.size();j++){ lint x=que.at(j); size.at(i)++; for(lint y:g.at(x)){ if(std::exchange(ckd.at(y),true))continue; que.push_back(y); } } } std::cout<<(std::count_if(ALL(size),[](lint x){return 1<x;})<=1?"YES":"NO")<<'\n'; }