QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#716538#9525. Welcome to Join the Online Meeting!EDGEWA 77ms27976kbC++201.3kb2024-11-06 15:28:462024-11-06 15:28:47

Judging History

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

  • [2024-11-06 15:28:47]
  • 评测
  • 测评结果:WA
  • 用时:77ms
  • 内存:27976kb
  • [2024-11-06 15:28:46]
  • 提交

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];
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);
            }
        }
    }
    for(int i=1;i<=n;i++) if(vis[i]) ++cnt;
    if(cnt!=n) {cout<<"No";return 0;}
    tmp=0;
    for(int i=1;i<=n;i++) if(l[i].size()) tmp++;
    cout<<"Yes\n"<<tmp<<"\n";
    for(int i=1;i<=n;i++){
        if(l[i].size()){
            cout<<i<<" ";
            cout<<l[i].size()<<" ";
            for(int j=0;j<l[i].size();j++) cout<<l[i][j]<<" ";cout<<"\n";
        }
    }
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 7724kb

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: 1ms
memory: 5840kb

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: 0
Accepted
time: 0ms
memory: 7668kb

input:

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

output:

Yes
1
1 3 3 4 2 

result:

ok ok

Test #4:

score: 0
Accepted
time: 0ms
memory: 5676kb

input:

6 6 0

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

output:

No

result:

ok ok

Test #5:

score: -100
Wrong Answer
time: 77ms
memory: 27976kb

input:

200000 199999 2
142330 49798
49798 116486
116486 64386
64386 192793
192793 61212
61212 138489
138489 83788
83788 89573
89573 8596
8596 156548
156548 41800
41800 14478
14478 27908
27908 82806
82806 9353
9353 160166
160166 92308
92308 36265
36265 126943
126943 190578
190578 191148
191148 177381
177381...

output:

Yes
199998
1 2 95113 178679 
2 1 198122 
3 1 41738 
4 1 196324 
5 1 91673 
6 1 796 
7 1 136018 
8 1 100182 
9 1 101606 
10 1 73864 
11 1 105951 
12 1 63827 
13 1 130553 
14 1 177897 
15 1 196567 
16 1 92389 
17 1 72182 
18 1 141202 
19 1 45379 
20 1 114057 
21 1 105287 
22 1 7260 
23 1 40268 
24 1 5...

result:

wrong answer on step #2, member 2 is not invited before inviting others