QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#706849 | #9525. Welcome to Join the Online Meeting! | the_foo# | WA | 0ms | 3752kb | C++20 | 1.3kb | 2024-11-03 13:41:43 | 2024-11-03 13:41:45 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int LL
using LL = long long;
void solve() {
int n,m,k;
cin>>n>>m>>k;
vector<bool> flag(n+1);
for(int i=0;i<k;i++) {
int _;
cin>>_;
flag[_] = true;
}
int p = 1;
while(p<=n && flag[p])p++;
if(p == n+1) {
cout<<"No"<<endl;
return ;
}
vector<vector<int> >G(n+1);
for(int i=0;i<m;i++) {
int u,v;
cin>>u>>v;
G[u].push_back(v);
G[v].push_back(u);
}
queue<pair<int,int> > que;
que.push({-1,p});
vector<pair<int,int>> res;
vector<bool> visited(n+1);
while(!que.empty()) {
auto [fa,to] = que.front();
que.pop();
if(visited[to])continue;
visited[to] = true;
res.push_back({fa,to});
if(flag[to])continue;
for(int i=0;i<G[to].size();i++) {
que.push({to,G[to][i]});
}
}
if(res.size() != n) {
cout<<"No"<<endl;
return ;
}
cout<<"Yes"<<endl;
cout<<n-1<<endl;
for(int i=1;i<res.size();i++) {
cout<<res[i].first<<' '<<1<<' '<<res[i].second<<endl;
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3752kb
input:
4 5 2 3 4 1 2 1 3 2 3 3 4 2 4
output:
Yes 3 1 1 2 1 1 3 2 1 4
result:
wrong answer on step #2, member 1 has invited someone before