結果
問題 |
No.2202 贅沢てりたまチキン
|
ユーザー |
|
提出日時 | 2023-02-12 02:57:20 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 94 ms / 2,000 ms |
コード長 | 860 bytes |
コンパイル時間 | 1,722 ms |
コンパイル使用メモリ | 196,052 KB |
最終ジャッジ日時 | 2025-02-10 14:38:52 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll=long long; using pii=pair<int,int>; #define all(a) a.begin(),a.end() #define pb push_back #define sz(a) ((int)a.size()) const int maxn=200005; int n,m,col[maxn]; vector<int> adj[maxn]; bool vis[maxn],flag; void dfs(int u){ vis[u]=1; for(auto v: adj[u]){ if(vis[v]){ if(col[u]^col[v]^1){ flag=1; } continue; } col[v]=col[u]^1; dfs(v); } } signed main(){ ios_base::sync_with_stdio(0),cin.tie(0); cin >> n >> m; for(int i=0; i<m; ++i){ int u,v; cin >> u >> v; u--,v--; adj[u].pb(v),adj[v].pb(u); } for(int i=0; i<n; ++i) if(!vis[i]){ flag=0; dfs(i); if(!flag){ cout << "No\n"; return 0; } } cout << "Yes\n"; }