QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#565424#9310. Permutation Counting 4RatzielCompile Error//C++14498b2024-09-15 21:15:332024-09-15 21:15:33

Judging History

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

  • [2024-09-18 14:56:40]
  • hack成功,自动添加数据
  • (/hack/835)
  • [2024-09-18 14:41:06]
  • hack成功,自动添加数据
  • (/hack/831)
  • [2024-09-17 12:14:52]
  • hack成功,自动添加数据
  • (/hack/825)
  • [2024-09-15 21:15:33]
  • 评测
  • [2024-09-15 21:15:33]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int T,n,en,h[1000005],fa[1000005];
inline int getfa(int x){while(x^fa[x])x=fa[x]=fa[fa[x]];return x;}
inline bool merge(int u,int v){return ((u=getfa(u))^(v=getfa(v)))&&(fa[u]=v,1);}
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>T;
	while(T --> 0)
	{
		cin>>n;en=0;
		for(int i=1;i<=n+1;++i)h[i]=deg[i]=0,fa[i]=i;
		int f=1;
		for(int i=1,l,r;i<=n;++i)cin>>l>>r,f=f&&merge(l,r+1);
		cout<<f<<endl;
	}
	return 0;
}

详细

answer.code: In function ‘int main()’:
answer.code:13:45: error: ‘deg’ was not declared in this scope
   13 |                 for(int i=1;i<=n+1;++i)h[i]=deg[i]=0,fa[i]=i;
      |                                             ^~~