結果
問題 | No.2202 贅沢てりたまチキン |
ユーザー | MAHAYANA |
提出日時 | 2023-10-26 00:14:18 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 131 ms / 2,000 ms |
コード長 | 1,429 bytes |
コンパイル時間 | 4,559 ms |
コンパイル使用メモリ | 172,448 KB |
実行使用メモリ | 6,472 KB |
最終ジャッジ日時 | 2023-10-26 00:14:27 |
合計ジャッジ時間 | 7,696 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,348 KB |
testcase_01 | AC | 2 ms
4,348 KB |
testcase_02 | AC | 2 ms
4,348 KB |
testcase_03 | AC | 2 ms
4,348 KB |
testcase_04 | AC | 2 ms
4,348 KB |
testcase_05 | AC | 2 ms
4,348 KB |
testcase_06 | AC | 2 ms
4,348 KB |
testcase_07 | AC | 2 ms
4,348 KB |
testcase_08 | AC | 2 ms
4,348 KB |
testcase_09 | AC | 2 ms
4,348 KB |
testcase_10 | AC | 5 ms
6,472 KB |
testcase_11 | AC | 1 ms
4,348 KB |
testcase_12 | AC | 2 ms
4,348 KB |
testcase_13 | AC | 1 ms
4,348 KB |
testcase_14 | AC | 114 ms
6,472 KB |
testcase_15 | AC | 116 ms
6,472 KB |
testcase_16 | AC | 92 ms
6,472 KB |
testcase_17 | AC | 91 ms
6,472 KB |
testcase_18 | AC | 44 ms
4,888 KB |
testcase_19 | AC | 65 ms
6,472 KB |
testcase_20 | AC | 121 ms
6,472 KB |
testcase_21 | AC | 119 ms
6,472 KB |
testcase_22 | AC | 78 ms
4,348 KB |
testcase_23 | AC | 93 ms
4,348 KB |
testcase_24 | AC | 93 ms
4,348 KB |
testcase_25 | AC | 131 ms
6,472 KB |
testcase_26 | AC | 115 ms
6,472 KB |
testcase_27 | AC | 113 ms
6,472 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll = long long; #define rep(i,m,n) for(int i=m; i<n; ++i) #define repl(i,m,n) for(ll i=m; i<n; ++i) struct UnionFind{ vector<int> size, parent; UnionFind(){} UnionFind(int n){ size.resize(n,0); parent.resize(n,0); for(int i=0; i<n; ++i){ make_tree(i); } } void make_tree(int x){ parent[x] = x; size[x] = 1; } bool is_same(int x, int y){ return find_root(x) == find_root(y); } bool unite(int x, int y){ x = find_root(x); y = find_root(y); if(x == y) return false; if(size[x] > size[y]){ parent[y] = x; size[x] += size[y]; }else{ parent[x] = y; size[y] += size[x]; } return true; } int find_root(int x){ if(x != parent[x]) parent[x] = find_root(parent[x]); return parent[x]; } int tree_size(int x){ return size[find_root(x)]; } }; int main(){ int N, L; cin >> N >> L; UnionFind uf(2*N); rep(i, 0, L){ int A, B; cin >> A >> B; A--, B--; uf.unite(A, B+N); uf.unite(A+N, B); } bool f = true; rep(i, 0, N){ if(!uf.is_same(i, i+N)){ f = false; break; } } cout << (f ? "Yes" : "No") << endl; return 0; }