QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#746391 | #9525. Welcome to Join the Online Meeting! | yyc4591# | WA | 1ms | 3536kb | C++20 | 1.6kb | 2024-11-14 14:28:50 | 2024-11-14 14:28:50 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 10;
vector<int> adj[N];
void solve()
{
int n, m, k;
cin >> n >> m >> k;
vector<pair<int, vector<int>>> ans;
vector<int> vis(n + 10, 0);
for (int i = 1; i <= k; i++) {
int t;
cin >> t;
vis[t] = 1;
}
for (int i = 1; i <= m; i++) {
int p, q;
cin >> p >> q;
adj[p].push_back(q);
adj[q].push_back(p);
}
queue<int> Q;
int cnt = 0;
vector<int> vis2(n + 10, 0);
for (int i = 1; i <= n; i++) {
if(!vis[i]) {
Q.push(i);
vis2[i] = 1;
++cnt;
break;
}
}
while(Q.size()) {
int u = Q.front();
Q.pop();
if(vis[u] == 1) continue;
vector<int> res;
for (auto v : adj[u]) {
if(++vis2[v] == 1) {
Q.push(v);
cnt++;
res.push_back(v);
}
}
if(res.size() == 0) continue;
ans.push_back({u, res});
}
if(cnt == n) {
cout << "Yes\n";
for (auto [u, res] : ans) {
cout << u << " ";
cout << res.size() << " ";
for (auto it : res) {
cout << it << " ";
}
cout << "\n";
}
} else {
cout << "No\n";
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T = 1;
// cin >> T;
while (T--)
solve();
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3536kb
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