QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#711362 | #9525. Welcome to Join the Online Meeting! | hcysxnn# | WA | 1ms | 3540kb | C++23 | 1.5kb | 2024-11-05 09:54:58 | 2024-11-05 09:55:00 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n, m, k;
std::cin >> n >> m >> k;
std::vector<bool> vis(n);
for (int i = 0; i < k; i++) {
int a;
std::cin >> a;
a--;
vis[a] = true;
}
std::vector<std::vector<int>> adj(n);
for (int i = 0; i < m; i++) {
int u, v;
std::cin >> u >> v;
u--, v--;
adj[u].push_back(v);
adj[v].push_back(u);
}
int t = -1;
for (int i = 0; i < n; i++) {
if (!vis[i]) {
t = i;
break;
}
}
if (t == -1) {
std::cout << "NO\n";
return 0;
}
std::vector<bool> ok(n);
std::vector<std::vector<int>> ans;
std::queue<int> q;
q.push(t);
ok[t] = true;
while (!q.empty()) {
int x = q.front();
q.pop();
std::vector<int> vec;
for (auto y : adj[x]) {
if (!ok[y]) {
ok[y] = true;
vec.push_back(y);
if (!vis[y]) {
q.push(y);
}
}
}
if (!vec.empty()) {
vec.push_back(x);
ans.push_back(vec);
}
}
for (int i = 0; i < n; i++) {
if (!ok[i]) {
std::cout << "NO\n";
return 0;
}
}
std::cout << "YES\n";
std::cout << ans.size() << "\n";
for (auto x : ans) {
std::cout << x.back() + 1 << " " << x.size() - 1 << " ";
for (int j = 0; j < x.size() - 1; j++) {
std::cout << x[j] + 1 << " ";
}
std::cout << "\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3540kb
input:
4 5 2 3 4 1 2 1 3 2 3 3 4 2 4
output:
YES 2 1 2 2 3 2 1 4
result:
wrong answer Token parameter [name=pans] equals to "YES", doesn't correspond to pattern "Yes|No"