/ tabris /

记录详情

Compile Error

/in/foo.c:1:19: fatal error: iostream: No such file or directory
 #include<iostream>
                   ^
compilation terminated.

代码

#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int n,m,fa[100005],c=1,T,num[100005],ans;
inline void init(){
	ans=n;
	for(int i=1;i<=n;++i) fa[i]=i,num[i]=1;
}
inline int find(int x){
	if(fa[x]==x) return x;
	else return fa[x]=find(fa[x]);
}
inline int change(int x){
	int t=0;
	for(int i=1;i<=n;++i){
		if(fa[i]=x&&i!=x){
			if(!t)t=i;
			else fa[i]=t;
		}
	}
	return t;
}
int main(){
	//freopen("game.in","w",stdin);
	//freopen("game.out","r",stdout);
	scanf("%d",&T);
	while(T--){
		printf("Case #%d\n",c);
		scanf("%d%d",&n,&m);
		init();
		while(m--){
			string s; int x,y;
			cin>>s;
			if(s=="query"){
				printf("%d\n",ans);
			}
			if(s=="fight"){
				scanf("%d%d",&x,&y);
				int xx=find(x),yy=find(y);
				if(xx==yy) continue;
				else if(num[xx]<num[yy]){
					printf("%d is winner\n",y);
					fa[xx]=yy;
					num[yy]+=num[xx];
					num[xx]=0;
					ans--;
				}
				else if(num[xx]>num[yy]){
					printf("%d is winner!\n",x);
					fa[yy]=xx;
					num[xx]+=num[yy];
					num[yy]=0;
					ans--;
				}
				else printf("Either is winner!\n");
			}
			if(s=="tempt"){
				scanf("%d%d",&x,&y);
				int xx=find(x),yy=find(y);
				if(y==yy){
					if(num[yy]==1){
						num[yy]--;
						ans--;
						fa[y]=xx;
						num[xx]++;
					}
					else{
						num[change(y)]=num[y]-1;
						num[yy]=0;
						fa[y]=xx;
						num[xx]++;
					}
				}
				else{
					num[xx]++; num[yy]--;
					fa[y]=xx;
				}
			}
			if(s=="revolt"){
				scanf("%d",&x);
				int xx=find(x);
				if(xx==x){
					if(num[x]==1) continue;
					else{
						num[change(x)]=num[x]-1;
						num[x]=1;
						ans++;
					}
				}
				num[xx]--;
				fa[x]=x;
				num[x]=1;
				ans++;
			}
		}
	}
}

信息

递交者
类型
递交
题目
幼儿园战争
语言
C
递交时间
2019-10-02 16:04:32
评测时间
2019-10-02 16:04:32
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes