結果

問題 No.2202 贅沢てりたまチキン
ユーザー i_am_noobi_am_noob
提出日時 2023-02-12 02:57:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 860 bytes
コンパイル時間 1,926 ms
コンパイル使用メモリ 201,160 KB
実行使用メモリ 21,760 KB
最終ジャッジ日時 2023-09-22 21:18:52
合計ジャッジ時間 5,742 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,140 KB
testcase_01 AC 4 ms
8,076 KB
testcase_02 AC 4 ms
8,184 KB
testcase_03 AC 4 ms
8,040 KB
testcase_04 AC 4 ms
8,016 KB
testcase_05 AC 4 ms
8,084 KB
testcase_06 AC 4 ms
8,312 KB
testcase_07 AC 4 ms
8,032 KB
testcase_08 AC 4 ms
8,188 KB
testcase_09 AC 4 ms
8,064 KB
testcase_10 AC 4 ms
8,032 KB
testcase_11 AC 4 ms
8,068 KB
testcase_12 AC 4 ms
8,032 KB
testcase_13 AC 4 ms
8,064 KB
testcase_14 AC 67 ms
21,496 KB
testcase_15 AC 68 ms
21,760 KB
testcase_16 AC 50 ms
15,728 KB
testcase_17 AC 50 ms
15,652 KB
testcase_18 AC 27 ms
11,636 KB
testcase_19 AC 36 ms
14,320 KB
testcase_20 AC 63 ms
15,512 KB
testcase_21 AC 64 ms
15,304 KB
testcase_22 AC 36 ms
10,512 KB
testcase_23 AC 48 ms
11,016 KB
testcase_24 AC 42 ms
10,960 KB
testcase_25 AC 113 ms
16,224 KB
testcase_26 AC 65 ms
18,416 KB
testcase_27 AC 64 ms
17,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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";
}
0