QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#639137 | #9310. Permutation Counting 4 | pl_er | WA | 0ms | 3832kb | C++14 | 456b | 2024-10-13 18:03:32 | 2024-10-13 18:03:33 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int t,n;
int f[100005];
int find(int x){
if(f[x]==x)return x;
return f[x]=find(f[x]);
}
int main(){
scanf("%d",&t);
while(t--){
scanf("%d",&n);
for(int i=1;i<=n;++i)f[i]=i;
int ans;
for(int i=1;i<=n;++i){
int l,r;
scanf("%d%d",&l,&r);
l=find(l-1);
r=find(r);
if(l==r){
ans=0;
break;
}else{
f[l]=r;
}
}
printf("%d",ans);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3832kb
input:
4 5 1 2 1 5 1 2 1 2 2 2 5 1 1 2 4 2 3 5 5 3 4 5 3 5 1 2 3 4 3 5 3 3 5 1 5 1 4 4 5 5 5 1 2
output:
0000
result:
wrong answer 1st words differ - expected: '0', found: '0000'