QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#709955 | #9525. Welcome to Join the Online Meeting! | 0x3fffffff | WA | 0ms | 3624kb | C++23 | 2.0kb | 2024-11-04 17:38:00 | 2024-11-04 17:38:02 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n, m, k;
cin >> n >> m >> k;
vector<int>a(n + 1);
vector<vector<int>>e(n + 1);
for (int i = 1;i <= k;i++) {
int x;cin >> x;
a[x] = 1;
}
vector<int>vis(n + 1);
vector<vector<int>>mp(n + 1);
int cnt = 0;
for (int i = 1;i <= m;i++) {
int a, b;cin >> a >> b;
e[a].push_back(b);
e[b].push_back(a);
}
vector<int>sf;
auto dfs = [&](auto ff, int u, int fa)->void {
vis[u] = 1;
if (a[u])return;
sf.push_back(u);
for (int v : e[u]) {
if (vis[v])continue;
mp[u].push_back(v);
}
for (int v : e[u]) {
if (vis[v])continue;
ff(ff, v, u);
}
};
for (int i = 1;i <= n;i++) {
if (!a[i]) {
dfs(dfs, i, 0);
break;
}
}
// if (sf.size() != n) {
// cout << "No\n";return;
// }
for (int i = 1;i <= n;i++) {
if (!vis[i]) {
cout << "No\n";return;
}
}
cout << "Yes\n";
fill(vis.begin(), vis.end(), 0);
reverse(sf.begin(), sf.end());
vector<int>ans;
while (sf.size()) {
if (mp[sf.back()].size()) {
ans.clear();
for (auto x : mp[sf.back()]) {
if (!vis[x]) {
vis[x] = 1;
ans.push_back(x);
}
}
if (ans.size()) {
cout << sf.back() << " " << ans.size() << " ";
for (auto x : ans) {
cout << x << " ";
}
cout << "\n";
}
}
sf.pop_back();
}
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
int T = 1;
#ifdef LOCAL
freopen("data.in", "r", stdin);
freopen("data.out", "w", stdout);
#endif
// cin >> T;
while (T--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3624kb
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