結果
問題 | No.2664 Prime Sum |
ユーザー |
![]() |
提出日時 | 2024-03-08 22:56:59 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 785 bytes |
コンパイル時間 | 2,696 ms |
コンパイル使用メモリ | 250,088 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-09-29 20:25:46 |
合計ジャッジ時間 | 3,862 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 37 |
ソースコード
#define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) v.begin(), v.end() typedef long long ll; #include <bits/stdc++.h> using namespace std; using Graph=vector<vector<int>>; vector<int> color; bool dfs(const Graph &G,int v,int cur=0){ color[v]=cur; for(auto next_v:G[v]){ if(color[next_v]!=-1){ if(color[next_v]==cur) return false; continue; } if(!dfs(G,next_v,1-cur)) return false; } return true; } int main(){ int n,m; cin>>n>>m; Graph G(n); rep(i,m){ int a,b; cin>>a>>b; a--,b--; G[a].push_back(b); G[b].push_back(a); } color.assign(n,-1); bool b=true; rep(v,n){ if(color[v]!=-1) continue; if(!dfs(G,v)) b=false; } if(b) cout<<"Yes"<<endl; else cout<<"No"<<endl; return 0; }