QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#743440#9525. Welcome to Join the Online Meeting!zxcdxwWA 0ms3564kbC++141.9kb2024-11-13 19:13:332024-11-13 19:13:39

Judging History

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

  • [2024-11-13 19:13:39]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3564kb
  • [2024-11-13 19:13:33]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

#define ull unsigned long long
#define ll long long
#define lowbit(x) (x)&(-x)
//#define int long long
//#define double long double 
const int N = 2e5 + 5;
const ll base = 131;
const ll mod = 998244353;
void solve() {
    int n,m,k;
    cin>>n>>m>>k;
    vector<int>a(n+1);
    for(int i=1;i<=k;++i){
        int x;
        cin>>x;
        a[x]=1;
    }
    vector<vector<int>>w(n+1);
    while(m--){
        int u,v;
        cin>>u>>v;
        w[u].push_back(v);
        w[v].push_back(u);
    }
    vector<int>vis(n+1),Vis(n+1);
    queue<int>q;
    for(int i=1;i<=n;++i){
        if(!a[i]){
            q.push(i);
            Vis[i]=1;
            //cerr<<i<<'\n';
            break;
        }
    }
    vector<vector<int>>as(n+1);
    vector<int>as1;
    while(!q.empty()){
        int now=q.front();
        q.pop();
        if(vis[now]) continue;
        vis[now]=1;
        Vis[now]=1;
        as1.push_back(now);
        for(int i=0;i<w[now].size();++i){
            int res=w[now][i];
            if(vis[res]) continue;
            if(!Vis[res]) as[now].push_back(res),Vis[res]=1;
            if(!vis[res]&&!a[res]) q.push(res),vis[res]=1;
        }
    }
    for(int i=1;i<=n;++i){
        if(!Vis[i]){
            //cerr<<i<<'\n';
            cout<<"No\n";
            return ;
        }
    }
    cout<<"Yes\n";
    int cnt=0;
    for(int i=1;i<=n;++i){
        cnt+=(as[i].size()>0);
    }
    cout<<cnt<<'\n';
    for(int i=0;i<as1.size();++i){
        if(as[as1[i]].empty()) continue;
        cout<<as1[i]<<" "<<as[as1[i]].size()<<" ";
        for(int j=0;j<as[as1[i]].size();++j) cout<<as[as1[i]][j]<<" ";
        cout<<'\n';
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) solve();
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3564kb

input:

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

output:

No

result:

wrong answer jury has found a solution, but participant hasn't