QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#713319 | #9525. Welcome to Join the Online Meeting! | Proaes | WA | 0ms | 3856kb | C++20 | 2.3kb | 2024-11-05 18:59:31 | 2024-11-05 18:59:35 |
Judging History
answer
/**
* title: g.cpp
* author: Proaes Meluam
* created: 2024-11-05 18:16:30
**/
#include <bits/stdc++.h>
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double pi = acos(-1);
const double E = exp(1);
constexpr ll mod = 1e9 + 7;
// constexpr int inf = 0x3f3f3f3f;
constexpr ll inf = 0x3f3f3f3f3f3f3f3f;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n, m, k;
cin >> n >> m >> k;
vector<int> s(k + 1);
vector<int> mp(n + 1, 1);
vector<int> vis(n + 1);
vector<int> fa(n + 1);
vector<vector<int>> adj1(n + 1, vector<int>(0));
vector<vector<int>> adj2(n + 1, vector<int>(0));
// vector<vector<int>> ans(n + 1, vector<int>(0));
vector<int> ans(0);
for (int i = 1; i <= k; ++ i) {
cin >> s[i];
mp[s[i]] = 0;
}
for (int i = 1; i <= m; ++ i) {
int u, v;
cin >> u >> v;
if (mp[u] == 1) adj1[u].emplace_back(v);
if (mp[v] == 1) adj1[v].emplace_back(u);
}
int root = 0;
for (int i = 1; i <= n; ++ i) {
if (mp[i] == 1) {
root = i;
break;
}
}
auto dfs1 = [&](auto self, int cur) -> void {
for (auto child : adj1[cur]) {
if (vis[child] == 1) continue;
vis[child] = 1;
self(self, child);
adj2[cur].emplace_back(child);
}
};
auto bfs = [&](int cur) {
queue<int> q;
q.push(cur);
while (q.size() > 0) {
int x = q.front();
q.pop();
int len = adj2[x].size();
if (len > 0) {
cout << x << " " << len << " ";
for (auto child : adj2[x]) {
q.push(child);
cout << child << " ";
}
cout << "\n";
}
}
};
vis[root] = 1;
dfs1(dfs1, root);
int all = 0;
for (int i = 1; i <= n; ++ i) {
int len = adj2[i].size();
all += len;
}
if (all + 1 == n) {
cout << "Yes\n";
bfs(root);
} else {
cout << "No\n";
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3856kb
input:
4 5 2 3 4 1 2 1 3 2 3 3 4 2 4
output:
Yes 1 1 2 2 2 3 4
result:
wrong answer on step #1, member 2 has been invited