QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#717977#9525. Welcome to Join the Online Meeting!20225954#WA 80ms27524kbC++201.6kb2024-11-06 19:26:062024-11-06 19:26:07

Judging History

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

  • [2024-11-06 19:26:07]
  • 评测
  • 测评结果:WA
  • 用时:80ms
  • 内存:27524kb
  • [2024-11-06 19:26:06]
  • 提交

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);
                }
            }
        }
        if(ans[now].size()==0) now--;
        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();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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

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

input:

6 6 0

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

output:

No

result:

ok ok

Test #5:

score: 0
Accepted
time: 80ms
memory: 27376kb

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 
95113 1 27292 
178679 1 186222 
27292 1 93394 
186222 1 122914 
93394 1 30051 
122914 1 18533 
30051 1 174891 
18533 1 66240 
174891 1 165580 
66240 1 143831 
165580 1 94294 
143831 1 52965 
94294 1 123410 
52965 1 45501 
123410 1 55130 
45501 1 36293 
55130 1 154872 
36...

result:

ok ok

Test #6:

score: 0
Accepted
time: 76ms
memory: 27524kb

input:

199999 199998 1
136702
159826 166341
166341 59559
59559 169672
169672 102084
102084 136269
136269 57057
57057 59116
59116 119963
119963 85663
85663 33942
33942 84604
84604 189395
189395 154906
154906 22175
22175 144902
144902 198523
198523 35993
35993 35690
35690 47504
47504 104458
104458 68253
6825...

output:

Yes
199997
1 2 172082 191801 
172082 1 188910 
191801 1 65736 
188910 1 131169 
65736 1 10794 
131169 1 48799 
10794 1 50503 
48799 1 20862 
50503 1 194943 
20862 1 189938 
194943 1 42759 
189938 1 46325 
42759 1 35447 
46325 1 48691 
35447 1 55027 
48691 1 45299 
55027 1 175222 
45299 1 166683 
175...

result:

ok ok

Test #7:

score: -100
Wrong Answer
time: 80ms
memory: 27404kb

input:

199998 199997 0

67665 130538
130538 101337
101337 73749
73749 138128
138128 1274
1274 108069
108069 50961
50961 7039
7039 109946
109946 170551
170551 193330
193330 113590
113590 92775
92775 2146
2146 43591
43591 125033
125033 75583
75583 173991
173991 46820
46820 3986
3986 163272
163272 91657
91657...

output:

Yes
199996
1 2 5661 102870 
5661 1 114962 
102870 1 182503 
114962 1 36222 
182503 1 106861 
36222 1 92959 
106861 1 147686 
92959 1 66511 
147686 1 106747 
66511 1 81220 
106747 1 182217 
81220 1 182229 
182217 1 124210 
182229 1 7906 
124210 1 72832 
7906 1 81750 
72832 1 107526 
81750 1 75132 
10...

result:

wrong answer on step #155179, member 2794 is not friend of 108040