QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#718212#9525. Welcome to Join the Online Meeting!Exile_Code#WA 1ms3848kbC++201.6kb2024-11-06 19:58:292024-11-06 19:58:31

Judging History

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

  • [2024-11-06 19:58:31]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3848kb
  • [2024-11-06 19:58:29]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

#define ll long long 
#define pii pair<ll,ll>
#define endl '\n'
#define vv vector
#define all(x) x.begin()+1,x.end()

#define int ll

#define ft first
#define sd second


void solve(){

    int n,m,k;cin>>n>>m>>k;

    queue<int>q;

    map<int,int>mp;
    for(int i=1;i<=k;i++){
        int a;cin>>a;
        mp[a]++;
    }

    vv<vv<int>>e(n+1);

    for(int i=1;i<=m;i++){
        int a,b;cin>>a>>b;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    vv<pair<int,vv<int>>>rs;
    for(int i=1;i<=n;i++){
        if(mp.find(i)==mp.end()){ 
            q.push(i);
            break;
        }
    }

    vv<int>flag(n+1);
    while(q.size()){
        int nd=q.front();
        q.pop();
        flag[nd]=1;
        vv<int>now;
        for(auto a:e[nd]){
            if(flag[a])
                continue;
            now.push_back(a);
            flag[a]=1;
            if(mp.find(a)==mp.end())
                q.push(a);
        }
        rs.push_back({nd,now});
    }


    for(int i=1;i<=n;i++)
        if(!flag[i]){
            cout<<"No"<<endl;
            return ;
        }

    cout<<"Yes"<<endl;
    cout<<rs.size()<<endl;
    for(int i=0;i<rs.size();i++){

        cout<<rs[i].first<<' '<<rs[i].second.size()<<' ';
        for(auto a:rs[i].second)
            cout<<a<<' ';
        cout<<endl;

    }



}
signed main(){

    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

    int _=1;
    //cin>>_;
    while(_--)
        solve();


    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3560kb

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: 0ms
memory: 3552kb

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: 0ms
memory: 3848kb

input:

4 6 2
3 4
1 3
1 4
2 3
2 4
1 2
3 4

output:

Yes
2
1 3 3 4 2 
2 0 

result:

wrong answer Integer parameter [name=y_j] equals to 0, violates the range [1, 4]