Submission #30996478
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
template <class T> inline T read(){
T r=0,f=0;char c=getchar();
while(!isdigit(c)) f|=c=='-',c=getchar();
while(isdigit(c)) r=r*10+(c^48),c=getchar();
return f?-r:r;
}
const int _=2e5+5;
int n,Q;
int ff[_];
int find(int x){return ff[x]==x?x:ff[x]=find(ff[x]);}
int main(){
n=read<int>(),Q=read<int>();
for(int i=1;i<=n;++i) ff[i]=i;
for(int i=1;i<=Q;++i){
int x=find(read<int>()-1),y=find(read<int>());
ff[x]=y;
}
puts(find(0)==find(n)?"Yes":"No");
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - Range Sums |
| User | Quick_Kk |
| Language | C++ (GCC 9.2.1) |
| Score | 500 |
| Code Size | 582 Byte |
| Status | AC |
| Exec Time | 32 ms |
| Memory | 4388 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 500 / 500 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| 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 |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 000.txt | AC | 32 ms | 4320 KiB |
| 001.txt | AC | 2 ms | 3532 KiB |
| 002.txt | AC | 2 ms | 4276 KiB |
| 003.txt | AC | 2 ms | 3604 KiB |
| 004.txt | AC | 15 ms | 3612 KiB |
| 005.txt | AC | 16 ms | 4152 KiB |
| 006.txt | AC | 22 ms | 4288 KiB |
| 007.txt | AC | 22 ms | 4252 KiB |
| 008.txt | AC | 5 ms | 4004 KiB |
| 009.txt | AC | 7 ms | 3540 KiB |
| 010.txt | AC | 26 ms | 4304 KiB |
| 011.txt | AC | 28 ms | 4276 KiB |
| 012.txt | AC | 27 ms | 4156 KiB |
| 013.txt | AC | 22 ms | 4272 KiB |
| 014.txt | AC | 27 ms | 4156 KiB |
| 015.txt | AC | 29 ms | 4320 KiB |
| 016.txt | AC | 29 ms | 4348 KiB |
| 017.txt | AC | 26 ms | 4388 KiB |
| 018.txt | AC | 31 ms | 4380 KiB |
| 019.txt | AC | 26 ms | 4164 KiB |
| 020.txt | AC | 24 ms | 4304 KiB |
| 021.txt | AC | 20 ms | 4196 KiB |
| 022.txt | AC | 22 ms | 4164 KiB |
| 023.txt | AC | 24 ms | 4336 KiB |
| 024.txt | AC | 26 ms | 4380 KiB |
| 025.txt | AC | 2 ms | 3908 KiB |
| 026.txt | AC | 13 ms | 3572 KiB |
| 027.txt | AC | 12 ms | 3440 KiB |
| 028.txt | AC | 16 ms | 3528 KiB |
| example0.txt | AC | 2 ms | 3572 KiB |
| example1.txt | AC | 2 ms | 3560 KiB |
| example2.txt | AC | 2 ms | 3564 KiB |