QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#719778#9525. Welcome to Join the Online Meeting!20225954WA 1ms5776kbC++201.4kb2024-11-07 08:50:382024-11-07 08:50:38

Judging History

你现在查看的是最新测评结果

  • [2024-11-07 08:50:38]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5776kb
  • [2024-11-07 08:50:38]
  • 提交

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