QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#717876#9525. Welcome to Join the Online Meeting!20225954#WA 2ms7040kbC++201.6kb2024-11-06 19:10:162024-11-06 19:10:16

Judging History

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

  • [2024-11-06 19:10:16]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:7040kb
  • [2024-11-06 19:10:16]
  • 提交

answer

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

#define ll long long

const int maxn=2e5+10;
int flag[maxn],busy[maxn];
queue<int> q;
vector<int> v[maxn];
vector<int> ans[maxn];
vector<int> u;

void solve(){
    int n,m,k;
    cin>>n>>m>>k;
    memset(flag,0,sizeof(flag));
    memset(busy,0,sizeof(busy));
    for(int i=1;i<=k;i++){
        int num;
        cin>>num;
        busy[num]=1;
    }
    for(int i=1;i<=m;i++){
        int a,b;
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    int fa=0;
    if(n==k){
        cout<<"No"<<'\n';
        return;
    }
    for(int i=1;i<=n;i++){
        if(!busy[i]){
            fa=i;
            break;
        }
    }
    
    q.push(fa);
    flag[fa]=1;
    int cnt=1;
    int now=0;
    while(!q.empty()){
        int num=q.front();
        q.pop();
        u.push_back(num);
        for(auto x:v[num]){
            if(!flag[x]){
                cnt++;
                flag[x]=1;
                ans[now].push_back(x);
                if(!busy[x]){
                    q.push(x);
                }
            }
        }
        now++;
    }
    if(cnt==n){
        cout<<"Yes"<<'\n';
        cout<<now<<'\n';
        for(int i=0;i<now;i++){
            cout<<u[i]<<" "<<ans[i].size()<<" ";
            for(auto x:ans[i]){
                cout<<x<<" ";
            }
            cout<<'\n';
        }
    }
    else{
        cout<<"No"<<'\n';
    }
}

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t;
    t=1;
    while(t--){
        solve();
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 7040kb

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: 5096kb

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: 5880kb

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]