UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#213375#2058. 小游戏Wonder_FunCompile Error//C++1.7kb2024-11-11 20:55:182024-11-11 23:04:35

answer

#include<bits/stdc++.h>
using namespace std;
int deg[400005],p[400005],vist[400005];
vector<int>g[400005],gg[400005];
bool pan(int x){
	sort(g[x].begin(),g[x].end());
	sort(gg[x].begin(),gg[x].end());
	return g[x]==gg[x];
}
int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		int n;
		scanf("%d",&n);
		for(int i=1;i<=n;++i){
			deg[i]=0;g[i].clear();gg[i].clear();
		}
		for(int i=1;i<=2*n-3;++i){
			int u,v;
			scanf("%d%d",&u,&v);
			if(u>v)swap(u,v);
			++deg[u],++deg[v];
			g[u].emplace_back(v);
			g[v].emplace_back(u);
		}
		int fl=1,f2=0,w=0;
		for(int i=1;i<=n;++i){
			if(deg[i]>4||deg[i]<2)fl=0;
			if(deg[i]==2)++f2,w=i;
		}
		if(!fl||f2!=2){
			puts("No");
			continue;
		}
		p[n]=w;
		int ww=0,wy=0;
		for(auto cu:g[w]){
			if(deg[cu]==3)ww=cu;
			wy^=cu;
		}
		if(!ww){
			puts("No");
			continue;
		}
		p[1]=ww;p[n-1]=ww^wy;
		for(int i=1;i<=n;++i)vist[i]=0;
		vist[p[1]]=vist[p[n-1]]=vist[p[n]]=1;
		int L=1,R=n-1,gs=0;
		while(R>L+1){
			if(gs==0){
				int w=0;
				for(auto cu:g[p[L]])if(!vist[cu])w=cu;
				if(!w){
					fl=0;break;
				}
				p[++L]=w;vist[w]=1;
			}else{
				int w=0;
				for(auto cu:g[p[R]])if(!vist[cu])w=cu;
				if(!w){
					fl=0;break;
				}
				p[--R]=w;vist[w]=1;
			}
			gs^=1;
		}
		if(!fl){
			puts("No");
			continue;
		}
		for(int i=1;i<n;++i){
			gg[p[i]].emplace_back(p[i+1]);
			gg[p[i+1]].emplace_back(p[i]);
		}
		L=1,R=n;
		gs=0;
		while(R>L+1){
			gg[p[L]].emplace_back(p[R]);
			gg[p[R]].emplace_back(p[L]);
			if(gs==0)--R;
			else ++L;
			gs^=1;
		}
		for(int i=1;i<=n;++i)fl&=pan(i);
		if(!fl){
			puts("No");
			continue;
		}
		puts("Yes");
	}
	return 0;
}

详细

answer.code: In function 'int main()':
answer.code:24:9: error: 'class std::vector<int>' has no member named 'emplace_back'
    g[u].emplace_back(v);\x0d
         ^
answer.code:25:9: error: 'class std::vector<int>' has no member named 'emplace_back'
    g[v].emplace_back(u);\x0d
         ^
answer.code:38:12: error: 'cu' does not name a type
   for(auto cu:g[w]){\x0d
            ^
answer.code:42:3: error: expected ';' before 'if'
   if(!ww){\x0d
   ^
answer.code:42:3: error: expected primary-expression befor...