QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#909295 | #9525. Welcome to Join the Online Meeting! | wxhtzdy# | WA | 0ms | 3712kb | C++20 | 1.3kb | 2025-02-21 17:42:16 | 2025-02-21 17:42:24 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, m, k;
cin >> n >> m >> k;
vector<bool> busy(n + 1, false);
for(int i = 0; i < k; i++) {
int x;
cin >> x;
busy[x] = true;
}
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);
}
vector<pair<int, vector<int>>> ans;
queue<int> q;
vector<bool> mark(n + 1, false);
for(int i = 1; i <= n; i++) {
if(!busy[i]) {
q.push(i);
mark[i] = true;
break;
}
}
if(q.empty()) {
cout << "No";
return 0;
}
vector<bool> in(n + 1, false);
while(!q.empty()) {
int u = q.front();
in[u] = true;
q.pop();
if(busy[u]) continue;
vector<int> add;
for(int v : g[u]) {
if(mark[v]) continue;
mark[v] = true;
q.push(v);
add.push_back(v);
}
ans.push_back({u, add});
}
for(int i = 1; i <= n; i++) {
if(!in[i]) {
cout << "No";
return 0;
}
}
cout << "Yes\n";
for(auto gas : ans) {
cout << gas.first << " " << gas.second.size() << " ";
for(int i : gas.second) cout << i << " ";
cout << "\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3712kb
input:
4 5 2 3 4 1 2 1 3 2 3 3 4 2 4
output:
Yes 1 2 2 3 2 1 4
result:
wrong answer on step #1, member 2 has been invited