QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#716561#9525. Welcome to Join the Online Meeting!EDGEWA 2ms7732kbC++201.3kb2024-11-06 15:32:282024-11-06 15:32:29

Judging History

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

  • [2024-11-06 15:32:29]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:7732kb
  • [2024-11-06 15:32:28]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 4e5 + 10;
int n,m,k;
int vis[maxn],vis1[maxn];
vector<int> e[maxn],l[maxn],ans;
void add(int x,int y){
    e[x].push_back(y);
}
queue<int> q;
int main(){
    ios::sync_with_stdio(false);
    cin>>n>>m>>k;
    for(int i=1;i<=k;i++){
        int x;
        cin>>x;
        vis1[x]=1;
    }
    for(int i=1;i<=m;i++){
        int x,y;
        cin>>x>>y;
        add(x,y);
        add(y,x);
    }
    for(int i=1;i<=n;i++) if(vis1[i]!=1){
        q.push(i);vis[i]=1;break;
    }
    int tmp;
    int cnt=0;
    while(!q.empty()){
        int u=q.front();
        q.pop();
        if(vis1[u]) continue;
        for(int i=0;i<e[u].size();i++){
            int v=e[u][i];
            if(!vis[v]){
                vis[v]=1;
                q.push(v);
                l[u].push_back(v);
            }
        }
        if(e[u].size()) ans.push_back(u);
    }
    for(int i=1;i<=n;i++) if(vis[i]) ++cnt;
    if(cnt!=n) {cout<<"No";return 0;}
    cout<<"Yes\n"<<ans.size()<<"\n";
    for(int i=0;i<ans.size();i++){
        if(l[ans[i]].size()){
            cout<<ans[i]<<" ";
            cout<<l[ans[i]].size()<<" ";
            for(int j=0;j<l[ans[i]].size();j++) cout<<l[ans[i]][j]<<" ";cout<<"\n";
        }
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 2ms
memory: 5552kb

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: 2ms
memory: 7720kb

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 

result:

wrong output format Unexpected end of file - int32 expected