QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#719812 | #9525. Welcome to Join the Online Meeting! | 20225954 | WA | 139ms | 18496kb | C++20 | 1.5kb | 2024-11-07 09:10:15 | 2024-11-07 09:10:15 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr<<#x<<(x)<<"\n"
#define db1(x) cerr<<#x<<(x)<<" "
#define rep(i,a,b) for(auto i = (a);i<=b;i++)
#define ll long long
const int N = 2e5+10;
int n,m,k;
int a[N];
using pii = pair<int,int>;
vector<pii> e;
int fa[N],vis[N],ok[N];
vector<int> ans[N];
int find(int x){
return x==fa[x]?x:fa[x] =find(fa[x]);
}
int main()
{
cin>>n>>m>>k;
rep(i,1,n)fa[i] =i;
for(int i=1;i<=k;i++){
int x;cin>>x;vis[x] =1;
}
for(int i=1;i<=m;i++){
int x,y;cin>>x>>y;
e.push_back({x,y});
}
for(auto [x,y]:e){
if(vis[x]&&vis[y])continue;
if(vis[x])swap(x,y);
if(ok[y])continue;
ans[x].push_back(y);
ok[x]= ok[y] =1;
if(find(x)==find(y))continue;
fa[find(y)] = find(x);
}
int num =0;
for(int i=1;i<=n;i++){
fa[i]= find(i);
if(fa[i]==i)++num;
}
// for(int i=1;i<=n;i++){
// db(fa[i]);
// }
// cout<<num<<"\n";
if(num==1){
cout<<"Yes\n";
int num1 =0;
for(int i=1;i<=n;i++){
if(ans[i].size())++num1;
}
cout<<num1<<"\n";
for(int i=1;i<=n;i++){
if(ans[i].size()){
cout<<i<<" "<<ans[i].size()<<" ";
for(auto x:ans[i]){
cout<<x<<" ";
}
cout<<"\n";
}
}
}else {
cout<<"No\n";
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5696kb
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:
ok ok
Test #2:
score: 0
Accepted
time: 1ms
memory: 5684kb
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: 0ms
memory: 5624kb
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: 1ms
memory: 3600kb
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
Wrong Answer
time: 139ms
memory: 18496kb
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 1 178679 2 1 198122 3 1 41738 4 1 61178 5 1 91673 6 1 151278 7 1 136018 8 1 100182 9 1 101606 10 1 160835 11 1 105951 12 1 169521 13 1 130553 14 1 147118 15 1 196567 16 1 50682 17 1 72182 18 1 141202 19 1 45379 20 1 130909 21 1 147232 22 1 114131 23 1 40268 24 1 5...
result:
wrong answer on step #2, member 2 is not invited before inviting others