QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#719778 | #9525. Welcome to Join the Online Meeting! | 20225954 | WA | 1ms | 5776kb | C++20 | 1.4kb | 2024-11-07 08:50:38 | 2024-11-07 08:50:38 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr<<#x<<(x)<<"\n"
#define db1(x) cerr<<#x<<(x)<<" "
#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];
vector<int> ans[N];
int find(int x){
return fa[x]==x?fa[x]:fa[x] =find(fa[x]);
}
int main()
{
cin>>n>>m>>k;
for(int i=1;i<=n;i++)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);
int fx =find(x),fy = find(y);
if(fx==fy)continue;
fa[fy] = fx;
ans[x].push_back(y);
}
for(int i=1;i<=n;i++){
fa[i] =find(i);
}
int num=0 ;
for(int i=1;i<=n;i++){
if(fa[i]==i)num++;
}
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";
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5684kb
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: 5700kb
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: -100
Wrong Answer
time: 1ms
memory: 5776kb
input:
4 6 2 3 4 1 3 1 4 2 3 2 4 1 2 3 4
output:
Yes 2 1 2 3 4 2 1 3
result:
wrong answer on step #2, member 2 is not invited before inviting others