QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#783508#9525. Welcome to Join the Online Meeting!Zpair#WA 1ms5928kbC++20762b2024-11-26 10:19:042024-11-26 10:19:05

Judging History

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

  • [2024-11-26 10:19:05]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5928kb
  • [2024-11-26 10:19:04]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int op[N],n,m,k;
vector<int> e[N];
bool vis[N];
int q[N],L,R;
vector<pair<int, int> > ans;
int main(){
	cin>>n>>m>>k;
	while(k--){
		int x;
		scanf("%d",&x);
		op[x]=1;
	}
	int x,y;
	while(m--){
		scanf("%d%d",&x,&y);
		e[x].push_back(y);
		e[y].push_back(x);
	}
	int p=-1;
	for(int i=1;i<=n;++i)
		if(!op[i])p=i;
	if(p==-1)puts("No"),exit(0);
	q[L=R=1]=p,vis[p]=1;
	while(L<=R){
		int p=q[L++];
		if(op[p])continue;
		for(int t:e[p])
			if(!vis[t]){
				ans.push_back({p,t});
				q[++R]=t;
				vis[t]=1;
			}
	}
	if(ans.size()<n-1)puts("No"),exit(0);
	puts("Yes");
	printf("%d\n",n);
	printf("%d\n",p);
	for(auto [x,y]:ans)
		printf("%d %d %d\n",x,1,y);
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5928kb

input:

4 5 2
3 4
1 2
1 3
2 3
3 4
2 4

output:

Yes
4
2
2 1 1
2 1 3
2 1 4

result:

wrong answer on step #1, member 1 has been invited