Submission #75266230
Source Code Expand
#include<iostream>
using namespace std;
int p[300001],s[300001];
int f(int x){
if(p[x]!=x){
p[x]=f(p[x]);
}
return p[x];
}
int main(){
int n,q;
cin>>n>>q;
for(int i=1;i<=n;i++){
p[i]=i;
s[i]=1;
}
for(int i=0;i<q;i++){
int a,b;
cin>>a>>b;
int x=f(a);
p[x]=b;
s[b]+=s[x];
}
for(int i=1;i<=n;i++){
if(p[i]==i){
cout<<s[i]<<'\n';
}
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Card Pile Query |
| User | ywrow |
| Language | C++23 (GCC 15.2.0) |
| Score | 0 |
| Code Size | 394 Byte |
| Status | WA |
| Exec Time | > 2000 ms |
| Memory | > 1048576 KiB |
Judge Result
| Set Name | Sample | All | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 400 | ||||||||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample00.txt, sample01.txt |
| All | sample00.txt, sample01.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt, testcase20.txt, testcase21.txt, testcase22.txt, testcase23.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| sample00.txt | WA | 1 ms | 3520 KiB |
| sample01.txt | MLE | 716 ms | > 1048576 KiB |
| testcase00.txt | MLE | 773 ms | > 1048576 KiB |
| testcase01.txt | MLE | 730 ms | > 1048576 KiB |
| testcase02.txt | WA | 30 ms | 4896 KiB |
| testcase03.txt | MLE | 711 ms | > 1048576 KiB |
| testcase04.txt | MLE | 682 ms | > 1048576 KiB |
| testcase05.txt | MLE | 708 ms | > 1048576 KiB |
| testcase06.txt | WA | 1 ms | 3300 KiB |
| testcase07.txt | MLE | 646 ms | > 1048576 KiB |
| testcase08.txt | WA | 108 ms | 5936 KiB |
| testcase09.txt | MLE | 1213 ms | > 1048576 KiB |
| testcase10.txt | MLE | 760 ms | > 1048576 KiB |
| testcase11.txt | WA | 111 ms | 6100 KiB |
| testcase12.txt | MLE | 1321 ms | > 1048576 KiB |
| testcase13.txt | TLE | > 2000 ms | > 1048576 KiB |
| testcase14.txt | WA | 137 ms | 5736 KiB |
| testcase15.txt | MLE | 1227 ms | > 1048576 KiB |
| testcase16.txt | WA | 2 ms | 3608 KiB |
| testcase17.txt | MLE | 653 ms | > 1048576 KiB |
| testcase18.txt | WA | 1 ms | 3480 KiB |
| testcase19.txt | MLE | 650 ms | > 1048576 KiB |
| testcase20.txt | MLE | 652 ms | > 1048576 KiB |
| testcase21.txt | MLE | 652 ms | > 1048576 KiB |
| testcase22.txt | MLE | 655 ms | > 1048576 KiB |
| testcase23.txt | MLE | 656 ms | > 1048576 KiB |