結果
問題 |
No.408 五輪ピック
|
ユーザー |
|
提出日時 | 2025-04-28 21:49:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,195 bytes |
コンパイル時間 | 1,033 ms |
コンパイル使用メモリ | 73,688 KB |
実行使用メモリ | 6,784 KB |
最終ジャッジ日時 | 2025-04-28 21:49:29 |
合計ジャッジ時間 | 2,380 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 WA * 2 |
ソースコード
#include<iostream> #include<vector> #define int long long #define maxn 50010 using namespace std; namespace IO{ int read(){ int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-')f=-f; ch=getchar(); } while(ch>='0'&&ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }return x*f; } void print(int x){ if(x<0){ x=-x; putchar('-'); } if(x>9)print(x/10); putchar(x%10+'0'); } }using namespace IO; int n,m,cnt[maxn],fa[maxn];bool vis[maxn]; vector<int>a,b,e[maxn]; signed main(){ // freopen("circle.in","r",stdin); // freopen("circle.out","w",stdout); n=read();m=read(); for(int i=1;i<=m;i++){ int u=read(),v=read(); e[u].push_back(v); e[v].push_back(u); if(u==1)a.push_back(v); if(v==1)a.push_back(u); } for(auto i:a)for(auto j:e[i]){ if(vis[j]){ cnt[j]++; continue; }cnt[j]++; fa[j]=i; vis[j]=1;b.push_back(j); } for(auto i:b){ for(auto j:e[i]){ bool t=1; if(!vis[j])continue; if(cnt[i]>=3||cnt[j]>=3){cout<<"YES";return 0;} for(auto k:e[j])if(k==1){t=0;break;} for(auto k:e[i])if(k==1){t=0;break;} if(cnt[i]==1&&cnt[j]==1&&fa[i]==fa[j])continue; if(t){cout<<"YES";return 0;} } }cout<<"NO"; return 0; }