QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#768915 | #9525. Welcome to Join the Online Meeting! | wk6_ | WA | 0ms | 13372kb | C++17 | 1.5kb | 2024-11-21 15:12:40 | 2024-11-21 15:12:43 |
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,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 dfs(int now){
vis[now]=1;
if(st[now]) return ;
idd[tot]=now;
for(auto s:g[now]){
if(vis[s]) continue;
dfs(s);
ans[now].push_back(s);
}
}
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);
}
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 13372kb
input:
4 5 2 3 4 1 2 1 3 2 3 3 4 2 4
output:
Yes 0
result:
wrong answer Integer parameter [name=t] equals to 0, violates the range [1, 4]