QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#760920#9525. Welcome to Join the Online Meeting!HanoistWA 59ms27908kbC++142.4kb2024-11-18 20:11:082024-11-18 20:11:09

Judging History

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

  • [2024-11-18 20:11:09]
  • 评测
  • 测评结果:WA
  • 用时:59ms
  • 内存:27908kb
  • [2024-11-18 20:11:08]
  • 提交

answer

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<functional>
#include<utility>
#include<cassert>
using namespace std;
inline long long read(){
    long long x = 0,f = 1;
    char c = getchar();
    while(c < '0' || c > '9'){
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9'){
        x = (x << 3) + (x << 1) + (c ^ 48);
        c = getchar();
    }
    return x * f;
}
const int N = 2e5 + 11;
const int M = 5e5 + 11;
int n,m,k,cnt,tt,head[N],ecnt = -1,id[N];
bool flag[N],vis[N];
vector<int> v[N];
queue<int> Q;
struct yjx{
    int nxt,to;
}e[M << 1];
inline void save(int x,int y){
    e[++ecnt] = (yjx){head[x],y};
    head[x] = ecnt;
}
void dfs(int now){
    int i,temp;
    //if(vis[now]) return;
    ++cnt;
    vis[now] = 1;
    for(i = head[now];~i;i = e[i].nxt){
        temp = e[i].to;
        if(vis[temp]) continue;
        else if(flag[temp]) ++cnt,vis[temp] = 1;
        else dfs(temp);
    }
}
void bfs(int s){
    int i,now,temp;
    Q.push(s);
    while(!Q.empty()){
        now = Q.front();
        Q.pop();
        if(vis[now]) continue;
        vis[now] = 1;
        id[++tt] = now;
        for(i = head[now];~i;i = e[i].nxt){
            temp = e[i].to;
            if(vis[temp]) continue;
            v[tt].push_back(temp);
            if(flag[temp]) vis[temp] = 1;
            else Q.push(temp);
        }
    }
}
int main(){
    int t,i,j,k,x,y,s;
    memset(head,-1,sizeof(head));
    n = read(),m = read(),k = read();
    for(i = 1;i <= k;i++){
        x = read();
        flag[x] = 1;
    }
    for(i = 1;i <= m;i++){
        x = read(),y = read();
        save(x,y),save(y,x);
    }
    for(i = 1;i <= n;i++){
        if(!flag[i]){
            s = i;
            dfs(s);
            break;
        }
    }
    if(cnt != n){
        puts("No");
        return 0;
    }
    puts("Yes");
    for(i = 1;i <= n;i++) vis[i] = 0;
    bfs(s);
    int res = 0;
    for(i = 1;i <= tt;i++){
        if(v[i].size() > 0) ++res;
    }
    printf("%d\n",res);
    for(i = 1;i <= tt;i++){
        if(!v[i].size()) continue;
        printf("%d %d ",id[i],(int)v[i].size());
        for(j = 0;j < (int)v[i].size();j++){
            printf("%d ",v[i][j]);
        }
        puts("");
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 10420kb

input:

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

output:

Yes
2
1 2 3 2 
2 1 4 

result:

ok ok

Test #2:

score: 0
Accepted
time: 3ms
memory: 11996kb

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: 3ms
memory: 12048kb

input:

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

output:

Yes
1
1 3 2 4 3 

result:

ok ok

Test #4:

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

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: 54ms
memory: 26300kb

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

result:

ok ok

Test #6:

score: 0
Accepted
time: 59ms
memory: 27656kb

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 191801 172082 
191801 1 65736 
172082 1 188910 
65736 1 10794 
188910 1 131169 
10794 1 50503 
131169 1 48799 
50503 1 194943 
48799 1 20862 
194943 1 42759 
20862 1 189938 
42759 1 35447 
189938 1 46325 
35447 1 55027 
46325 1 48691 
55027 1 175222 
48691 1 45299 
175222 1 103541 
45...

result:

ok ok

Test #7:

score: 0
Accepted
time: 51ms
memory: 27908kb

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 102870 5661 
102870 1 182503 
5661 1 114962 
182503 1 106861 
114962 1 36222 
106861 1 147686 
36222 1 92959 
147686 1 106747 
92959 1 66511 
106747 1 182217 
66511 1 81220 
182217 1 124210 
81220 1 182229 
124210 1 72832 
182229 1 7906 
72832 1 107526 
7906 1 81750 
107526 1 187820 
...

result:

ok ok

Test #8:

score: 0
Accepted
time: 7ms
memory: 18556kb

input:

199997 199996 1
158877
35837 79489
79489 72932
72932 14238
14238 73007
73007 66909
66909 49015
49015 129581
129581 138449
138449 94774
94774 189625
189625 23578
23578 31043
31043 146625
146625 161587
161587 136966
136966 184859
184859 27587
27587 155616
155616 72392
72392 195320
195320 75551
75551 1...

output:

No

result:

ok ok

Test #9:

score: 0
Accepted
time: 8ms
memory: 15252kb

input:

200000 199999 1
29111
29111 80079
29111 131587
29111 197066
29111 125194
29111 156736
50697 29111
29111 74382
113595 29111
29111 26046
29111 172868
178564 29111
174875 29111
93471 29111
88216 29111
29111 147893
29111 145746
29111 34038
146500 29111
67862 29111
29111 19222
29111 121535
29111 49102
29...

output:

No

result:

ok ok

Test #10:

score: 0
Accepted
time: 24ms
memory: 15264kb

input:

199999 199998 2
52512 104330
130511 66864
139434 66864
92884 66864
66864 185580
184115 66864
137395 66864
66864 43463
118395 66864
111697 66864
66864 133237
66864 112507
66864 140264
66864 10
66864 151082
155779 66864
107988 66864
148839 66864
66864 40909
172685 66864
66864 189374
180054 66864
49 66...

output:

Yes
2
1 1 66864 
66864 199997 152191 114634 139293 174586 166708 148083 113473 51973 40621 24729 76417 61418 8724 198149 133889 48404 16570 71892 189896 124248 97342 29065 127677 122933 54921 187274 29825 42364 38058 57622 184269 136390 73229 94147 195417 121369 139089 119860 191448 131894 139973 58...

result:

ok ok

Test #11:

score: 0
Accepted
time: 24ms
memory: 17088kb

input:

199998 199997 0

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

output:

Yes
2
1 1 77056 
77056 199996 108040 162420 130135 168898 4125 67434 132013 36554 114001 171315 14656 37474 46087 66480 161076 103822 131635 148656 136590 125073 111510 124527 62120 126154 40223 33351 140740 48401 168088 47 53313 116117 151667 51110 55915 195842 151790 175746 63508 8461 184584 11119...

result:

ok ok

Test #12:

score: 0
Accepted
time: 8ms
memory: 17500kb

input:

1000 499500 999
458 720 932 821 847 788 447 593 430 896 257 238 380 924 968 30 389 306 278 824 83 342 329 513 476 313 714 348 602 105 758 777 663 1000 20 756 546 256 123 340 69 244 772 625 390 557 911 272 496 127 409 436 845 574 958 921 24 17 770 630 851 147 178 976 77 181 230 723 974 345 501 683 24...

output:

Yes
1
987 999 422 67 813 291 807 123 296 89 197 428 396 13 499 402 102 796 607 254 889 483 777 761 956 233 490 913 609 147 149 163 789 574 648 753 783 107 379 129 427 184 627 313 852 409 470 856 504 774 756 90 403 532 20 672 932 924 634 495 876 649 232 457 942 885 890 16 307 337 693 599 850 755 863 ...

result:

ok ok

Test #13:

score: -100
Wrong Answer
time: 35ms
memory: 18432kb

input:

1000 499000 765
622 257 281 601 593 967 704 173 609 700 782 592 356 595 431 307 933 886 213 478 8 832 877 606 335 253 420 631 345 179 961 437 238 641 513 997 192 483 152 951 580 331 401 122 155 814 228 633 372 918 346 464 3 992 416 953 650 668 971 899 76 575 880 85 194 541 26 348 93 815 554 64 850 5...

output:

Yes
234
1 999 335 155 671 709 729 722 151 199 363 557 629 502 114 227 139 291 366 200 683 492 661 771 213 654 405 749 380 796 656 994 919 288 317 976 273 164 843 146 165 215 791 30 646 150 427 187 299 387 649 867 437 329 614 724 728 206 128 246 860 948 974 140 189 936 531 736 997 598 659 421 777 584...

result:

wrong answer on step #2, member 987 has been invited