QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#597952#9310. Permutation Counting 4Jin_ChuantiCompile Error//C++14515b2024-09-28 19:36:132024-09-28 19:36:13

Judging History

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

  • [2024-09-28 19:36:13]
  • 评测
  • [2024-09-28 19:36:13]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

const int N = 1e6 + 10;
int a[N] = {0};

int find(int n){
	return a[n] == n ? n : f[n] = find(f[n]);
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int t, n, l, r, jg;
	cin >> t;
	while(t--){
		cin >> n;
		jg = 1;
		for(int i = 0; i <= n; i++)	a[i] = i;
		for(int i = 0; i <= n; i++){
			cin >> l >> r;
			if(find(l - 1) == find(r)) jg = 0;
			else a[find(l - 1)] = find(r); 
		}
		printf("%d\n",jg);
	}
 	return 0;
}

详细

answer.code: In function ‘int find(int)’:
answer.code:8:32: error: ‘f’ was not declared in this scope
    8 |         return a[n] == n ? n : f[n] = find(f[n]);
      |                                ^