QOJ.ac

QOJ

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

Judging History

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

  • [2024-11-06 19:09:06]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:6580kb
  • [2024-11-06 19:08:57]
  • 提交

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';
        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: 0
Wrong Answer
time: 2ms
memory: 6580kb

input:

4 5 2
3 4
1 2
1 3
2 3
3 4
2 4

output:

YES
1 2 2 3 
2 1 4 

result:

wrong answer Token parameter [name=pans] equals to "YES", doesn't correspond to pattern "Yes|No"