QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#768913 | #9525. Welcome to Join the Online Meeting! | wk6_ | RE | 3ms | 14956kb | C++17 | 1.5kb | 2024-11-21 15:11:23 | 2024-11-21 15:11:32 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define inf 0x3f3f3f3f3f3f3f3f
#define PII pair<int, int>
const int N = 2e5 + 10;
//int n, m, k;
//vector<int>g[N], ans[N];
//bool vis[N], st[N];
//int idd[N], tot;
int n,m,k,fa,tot;
vector<int> g[N],ans[N];
int idd[N];
bool st[N],vis[N];
void dfs(int now) {
vis[now] = 1;
if (st[now])return ;
idd[++tot] = now;
for (auto i : g[now]) {
if (vis[i])continue;
dfs(i);
ans[now].push_back(i);
}
}
void solve() {
cin >> n >> m >> k;
for (int i = 1; i <= k; i++) {
int x;
cin>>x;
st[x] = 1;
}
for (int i = 1; i <= m; i++) {
int u, v;
cin >> u >> v;
g[u].push_back(v);
g[v].push_back(u);
}
int fa = 0;
for (int i = 1; i <= n; i++) {
if (!st[i]) {
fa = i;
break;
}
}
dfs(fa);
for (int i = 1; i <= n; i++) {
if (!vis[i]) {
cout << "No" << endl;
return ;
}
}
int num = 0;
for (int i = 1; i <= tot; i++) {
int tmp = idd[i];
if (!ans[tmp].size())num++;
}
cout << "Yes" << endl << tot - num << endl;
for (int i = 1; i <= tot; i++) {
int tmp = idd[i];
if (!ans[tmp].size())continue;
cout << tmp << " " << ans[tmp].size() << " ";
for (int j = 0; j < ans[tmp].size(); j++) {
cout << ans[i][j] << " ";
}
cout << endl;
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int _ = 1;
// cin >> _;
while (_--) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 14956kb
input:
4 5 2 3 4 1 2 1 3 2 3 3 4 2 4
output:
Yes 2 1 1 2 2 2 3 4
result:
ok ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 14776kb
input:
4 5 3 2 4 3 1 2 1 3 2 3 3 4 2 4
output:
No
result:
ok ok
Test #3:
score: 0
Accepted
time: 3ms
memory: 14184kb
input:
4 6 2 3 4 1 3 1 4 2 3 2 4 1 2 3 4
output:
Yes 1 1 3 3 4 2
result:
ok ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 13736kb
input:
6 6 0 1 2 2 3 3 1 4 5 5 6 6 4
output:
No
result:
ok ok
Test #5:
score: -100
Runtime Error
input:
200000 199999 2 142330 49798 49798 116486 116486 64386 64386 192793 192793 61212 61212 138489 138489 83788 83788 89573 89573 8596 8596 156548 156548 41800 41800 14478 14478 27908 27908 82806 82806 9353 9353 160166 160166 92308 92308 36265 36265 126943 126943 190578 190578 191148 191148 177381 177381...
output:
Yes 199998 1 2 95113 178679 95113 1 198122 27292 1 41738 93394 1 196324 30051 1 91673 174891 1 796 165580 1 136018 94294 1 100182 123410 1 101606 55130 1 73864 154872 1 105951 166138 1 63827 30681 1 130553 51031 1 177897 89161 1 196567 187764 1 92389 14291 1 72182 66035 1 141202 83...