QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#572319#9310. Permutation Counting 4wjh111WA 0ms3644kbC++14420b2024-09-18 13:41:412024-09-18 13:41:42

Judging History

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

  • [2024-09-18 14:56:40]
  • hack成功,自动添加数据
  • (/hack/835)
  • [2024-09-18 14:41:06]
  • hack成功,自动添加数据
  • (/hack/831)
  • [2024-09-18 13:41:42]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3644kb
  • [2024-09-18 13:41:41]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int t,n,f[1000005];
int find(int x){
  return f[x]?find(f[x]):x;
}
bool m(int u,int v){
	if (find(u)==find(v)){
		return 0;
	}
	f[v]=u;
	return 1;
}
int main(){
  cin>>t;
  while(t--){
    cin>>n;
    bool ans=1;
    for(int i=1,l,r;i<=n;i++){
	cin>>l>>r;if (m(l,r+1)==0){
    	ans=0;
	}}
    cout<<ans<<"\n";
    for(int i=1;i<=n+1;i++)f[i]=0;
  }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3644kb

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:

0
1
0
1

result:

wrong answer 4th words differ - expected: '0', found: '1'