QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#783508 | #9525. Welcome to Join the Online Meeting! | Zpair# | WA | 1ms | 5928kb | C++20 | 762b | 2024-11-26 10:19:04 | 2024-11-26 10:19:05 |
Judging History
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