QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#783513 | #9525. Welcome to Join the Online Meeting! | Zpair# | WA | 1ms | 3908kb | C++20 | 744b | 2024-11-26 10:20:22 | 2024-11-26 10:20:23 |
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-1);
for(auto [x,y]:ans)
printf("%d %d %d\n",x,1,y);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3908kb
input:
4 5 2 3 4 1 2 1 3 2 3 3 4 2 4
output:
Yes 3 2 1 1 2 1 3 2 1 4
result:
wrong answer on step #2, member 2 has invited someone before