ログインしてください。
提出 #29412304
ソースコード 拡げる
#include <iostream>
using namespace std;
const int N = 2e5 + 10;
int fa[N];
int find(int x) {
if(x == fa[x]) return x;
return fa[x] = find(fa[x]);
}
void merge(int x,int y) {
x = find(x) , y = find(y);
if(x > y) swap(x , y);
fa[y] = x;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n , q ;
cin >> n >> q;
for (int i = 1 ; i <= n ; i ++ ) fa[i] = i;
while(q--) {
int x , y ; cin >> x >> y ;
merge(x - 1, y);
}
if(find(n) == 0) puts("Yes");
else puts("No");
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | E - Range Sums |
| ユーザ | RealKing |
| 言語 | C++ (GCC 9.2.1) |
| 得点 | 500 |
| コード長 | 599 Byte |
| 結果 | AC |
| 実行時間 | 46 ms |
| メモリ | 4436 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 500 / 500 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | example0.txt, example1.txt, example2.txt |
| All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, example0.txt, example1.txt, example2.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 000.txt | AC | 43 ms | 4388 KiB |
| 001.txt | AC | 3 ms | 3564 KiB |
| 002.txt | AC | 5 ms | 4380 KiB |
| 003.txt | AC | 2 ms | 3540 KiB |
| 004.txt | AC | 23 ms | 3732 KiB |
| 005.txt | AC | 29 ms | 4156 KiB |
| 006.txt | AC | 36 ms | 4184 KiB |
| 007.txt | AC | 34 ms | 4200 KiB |
| 008.txt | AC | 11 ms | 3996 KiB |
| 009.txt | AC | 9 ms | 3728 KiB |
| 010.txt | AC | 43 ms | 4436 KiB |
| 011.txt | AC | 42 ms | 4204 KiB |
| 012.txt | AC | 43 ms | 4324 KiB |
| 013.txt | AC | 41 ms | 4244 KiB |
| 014.txt | AC | 40 ms | 4248 KiB |
| 015.txt | AC | 40 ms | 4372 KiB |
| 016.txt | AC | 40 ms | 4368 KiB |
| 017.txt | AC | 46 ms | 4400 KiB |
| 018.txt | AC | 40 ms | 4404 KiB |
| 019.txt | AC | 41 ms | 4252 KiB |
| 020.txt | AC | 35 ms | 4320 KiB |
| 021.txt | AC | 41 ms | 4352 KiB |
| 022.txt | AC | 41 ms | 4240 KiB |
| 023.txt | AC | 41 ms | 4416 KiB |
| 024.txt | AC | 41 ms | 4392 KiB |
| 025.txt | AC | 3 ms | 3968 KiB |
| 026.txt | AC | 31 ms | 3548 KiB |
| 027.txt | AC | 31 ms | 3596 KiB |
| 028.txt | AC | 33 ms | 3652 KiB |
| example0.txt | AC | 3 ms | 3604 KiB |
| example1.txt | AC | 2 ms | 3588 KiB |
| example2.txt | AC | 2 ms | 3536 KiB |