QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#639137#9310. Permutation Counting 4pl_erWA 0ms3832kbC++14456b2024-10-13 18:03:322024-10-13 18:03:33

Judging History

你现在查看的是最新测评结果

  • [2024-10-13 18:03:33]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3832kb
  • [2024-10-13 18:03:32]
  • 提交

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'