QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#692054 | #9525. Welcome to Join the Online Meeting! | Nanani | AC ✓ | 141ms | 71260kb | C++17 | 2.3kb | 2024-10-31 13:42:34 | 2024-10-31 13:42:36 |
Judging History
answer
//by 72
#include<bits/stdc++.h>
#define F(i, a, b) for(int i = a; i <= b; i ++)
#define Fd(i, a, b) for(int i = a; i >= b; i --)
#define pb push_back
#define pii pair<int, int>
#define fi first
#define se second
#define int long long
using namespace std;
const int mod = 998244353;
const int N = 5e5 + 10;
const int inf = 1e18;
typedef array<int, 3> a3;
typedef long long ll;
int n, m, k, f[N];
vector<int> ed[N];
pii E[N];
int find(int x) {return x == f[x] ? x : f[x] = find(f[x]);}
bool merge(int u, int v) {
int p = find(u), q = find(v);
if(p == q) return false;
f[p] = q;
return true;
}
vector<int> tr[N];
vector<int> res[N];
vector<int> now;
void dfs(int u, int fa) {
now.push_back(u);
res[fa].push_back(u);
for(auto v : tr[u]) {
if(v == fa) continue;
dfs(v, u);
}
}
void sol() {
cin >> n >> m >> k;
vector<int> b(k + 1);
vector<int> vst(n + 1);
F(i, 1, k) cin >> b[i], vst[b[i]] = 1;
int idx = 0;
F(i, 1, m) {
int u, v; cin >> u >> v;
if(vst[u] && vst[v]) continue;
if(vst[u]) ed[u].pb(v);
else if(vst[v]) ed[v].pb(u);
else E[++ idx] = {u, v};
}
F(i, 1, n) f[i] = i;
F(i, 1, idx) {
auto [u, v] = E[i];
if(merge(u, v)) tr[u].push_back(v), tr[v].push_back(u);
}
map<int, int> cnt;
F(i, 1, n) {
if(vst[i]) {
if(! ed[i].size()) {
cout << "No\n";
return;
}
tr[ed[i][0]].push_back(i), tr[i].push_back(ed[i][0]);
} else {
cnt[find(i)] ++;
}
}
if(cnt.size() != 1) {
cout << "No\n";
return;
}
int st = -1;
F(i, 1, n) if(! vst[i]) st = i;
if(st == -1) {
cout << "No\n";
return;
}
dfs(st, 0);
cout << "Yes\n";
int qaq = 0;
for(auto x : now) if(res[x].size()) qaq ++;
cout << qaq << "\n";
for(auto x : now) if(res[x].size()) {
cout << x << " " << res[x].size() << " ";
for(auto v : res[x]) cout << v << " "; cout << "\n";
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t = 1;
// cin >> t;
F(i, 1, t) sol();
return 0;
}
//sldl
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 41004kb
input:
4 5 2 3 4 1 2 1 3 2 3 3 4 2 4
output:
Yes 2 2 2 1 4 1 1 3
result:
ok ok
Test #2:
score: 0
Accepted
time: 3ms
memory: 41912kb
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: 4ms
memory: 41656kb
input:
4 6 2 3 4 1 3 1 4 2 3 2 4 1 2 3 4
output:
Yes 2 2 1 1 1 2 3 4
result:
ok ok
Test #4:
score: 0
Accepted
time: 4ms
memory: 41008kb
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: 84ms
memory: 71260kb
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 200000 2 70619 64617 70619 1 61733 61733 1 186765 186765 1 130197 130197 1 60967 60967 1 185321 185321 1 175404 175404 1 36785 36785 1 46281 46281 1 117056 117056 1 196740 196740 1 106390 106390 1 80009 80009 1 93912 93912 1 182518 182518 1 156904 156904 1 108072 108072 1...
result:
ok ok
Test #6:
score: 0
Accepted
time: 83ms
memory: 68636kb
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 199999 2 164642 146100 164642 1 189122 189122 1 68022 68022 1 112813 112813 1 29929 29929 1 81207 81207 1 182732 182732 1 94588 94588 1 198013 198013 1 180555 180555 1 123535 123535 1 144321 144321 1 164463 164463 1 53519 53519 1 129611 129611 1 85679 85679 1 1403 1403 1 ...
result:
ok ok
Test #7:
score: 0
Accepted
time: 92ms
memory: 70080kb
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 199998 2 193401 179438 193401 1 135386 135386 1 20788 20788 1 149607 149607 1 52583 52583 1 35364 35364 1 1465 1465 1 175228 175228 1 49013 49013 1 104480 104480 1 78367 78367 1 48226 48226 1 53593 53593 1 164579 164579 1 146147 146147 1 180648 180648 1 77787 77787 1 9253...
result:
ok ok
Test #8:
score: 0
Accepted
time: 45ms
memory: 52984kb
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: 56ms
memory: 57956kb
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: 62ms
memory: 59616kb
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 199999 1 66864 66864 199997 130511 139434 92884 185580 184115 137395 43463 118395 111697 133237 112507 140264 10 151082 155779 107988 148839 40909 172685 189374 180054 49 41830 19259 186287 41932 21357 66485 95229 126195 72801 154651 48615 111519 156500 156919 60203 11260 164641 168543 130264...
result:
ok ok
Test #11:
score: 0
Accepted
time: 46ms
memory: 59364kb
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 199998 1 77056 77056 199996 67665 130538 101337 73749 138128 1274 108069 50961 7039 109946 170551 193330 113590 92775 2146 43591 125033 75583 173991 46820 3986 163272 91657 92212 191670 170218 149297 164182 6856 61891 95065 7257 47282 126716 84031 52189 32847 63118 134126 143246 30142 58215 3...
result:
ok ok
Test #12:
score: 0
Accepted
time: 40ms
memory: 42272kb
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 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...
result:
ok ok
Test #13:
score: 0
Accepted
time: 41ms
memory: 43708kb
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 998 2 349 574 349 5 805 347 277 483 725 805 3 651 123 726 651 3 696 16 611 696 3 160 827 983 347 6 523 59 267 283 336 454 523 9 337 596 18 36 171 181 366 572 801 337 8 115 503 364 57 122 498 615 974 115 3 811 860 622 811 6 53 537 135 830 594 909 53 2 174 1000 174 4 451 244 250 994...
result:
ok ok
Test #14:
score: 0
Accepted
time: 25ms
memory: 46828kb
input:
999 300000 98 544 367 966 146 474 309 291 482 953 116 340 59 765 566 227 176 371 672 170 739 120 931 23 858 153 884 258 842 763 405 104 957 596 978 732 515 497 269 174 551 653 690 755 808 288 574 17 356 500 665 827 172 987 240 154 824 220 430 722 950 534 400 413 908 671 12 427 818 187 335 572 644 52...
output:
Yes 563 999 3 401 109 964 109 1 360 360 1 48 964 2 888 781 888 2 712 285 712 1 40 40 2 205 284 205 4 507 181 932 824 507 3 619 930 26 619 2 592 765 930 3 955 256 907 955 2 896 348 896 2 245 301 348 2 79 580 79 1 927 580 3 417 868 541 417 1 261 261 1 638 868 2 364 935 364 1 885 93...
result:
ok ok
Test #15:
score: 0
Accepted
time: 44ms
memory: 41104kb
input:
10000 500000 10000 1905 4872 6021 8458 3220 7251 6356 3194 996 2320 298 7850 3567 2244 4361 7462 8058 9852 3057 6409 2288 9712 8533 5380 7131 970 2261 134 1179 1665 7329 442 8996 8203 7168 5946 7893 8282 9474 2445 1762 4900 101 6631 4588 7670 7716 7010 6113 5654 5308 3451 130 3205 2959 4898 374 6178...
output:
No
result:
ok ok
Test #16:
score: 0
Accepted
time: 45ms
memory: 42032kb
input:
10000 500000 9998 5272 7519 3021 7043 2522 2940 9960 3860 7595 3760 8035 2085 572 234 8292 3636 9619 6749 884 6669 8536 570 9353 2803 160 6085 5838 2812 7764 8722 2431 8854 2183 2032 7731 5404 5516 1574 4864 1431 8527 5506 1012 5713 8665 26 976 6010 4888 5975 6993 3187 7227 8438 6812 5903 1738 6467 ...
output:
No
result:
ok ok
Test #17:
score: 0
Accepted
time: 46ms
memory: 48628kb
input:
10000 500000 1234 7096 8517 9305 874 7758 730 2653 6237 2494 4290 2280 892 9081 2308 6418 3258 1690 103 9850 6778 9724 1914 1561 1361 3776 160 1892 1394 7981 3050 6013 5452 8769 7341 3259 6011 8672 4500 1930 8758 5103 4509 2782 1354 1583 8663 1088 2156 3254 7150 3824 4768 8230 7533 3277 8910 8135 19...
output:
Yes 5685 10000 1 4498 4498 5 5178 4119 324 4746 9995 4119 3 5104 8002 1571 5104 3 9283 1651 6650 9283 1 3869 3869 2 1035 6791 1035 3 1020 1331 7727 1020 2 4798 9207 4798 4 8142 8225 6277 3123 8225 1 7940 7940 3 5766 6544 6019 5766 1 1181 1181 1 2128 6544 4 4716 669 9202 5967 4716 3 154...
result:
ok ok
Test #18:
score: 0
Accepted
time: 40ms
memory: 49176kb
input:
10000 500000 0 6605 3715 1237 3040 3617 2124 4550 1766 8159 4808 7027 9779 7053 1803 3973 6790 8233 2873 7636 6894 6821 9714 8280 8440 261 6160 1279 3627 5816 9131 8167 1332 6763 3029 9605 4045 921 9926 6547 4760 3618 7832 5961 6497 1255 5646 5567 621 5732 2860 88 3501 3866 6046 7188 6203 3337 2873...
output:
Yes 5959 10000 1 1654 1654 2 6131 1612 1612 2 8874 1977 8874 2 8562 6775 8562 3 6562 9653 2908 6562 2 3982 352 3982 1 5991 5991 4 134 302 1559 8249 134 1 4962 4962 1 9963 302 2 6686 1641 1641 2 19 2241 19 4 159 3288 4154 5485 159 3 4908 143 7525 4908 1 4287 143 2 2108 6980 2108 1 988...
result:
ok ok
Test #19:
score: 0
Accepted
time: 62ms
memory: 48608kb
input:
20000 499999 321 13495 16729 10971 3389 7920 17768 11943 12054 6426 13331 6453 15959 6842 12610 18437 12930 4597 7386 8506 52 17373 2492 18849 19694 8432 12552 8663 4836 5370 3125 4323 15529 5916 14378 13756 15147 19826 7961 3188 4919 14256 5230 16288 13867 6039 13451 12861 9057 12645 19486 16719 19...
output:
Yes 11702 20000 1 9523 9523 2 131 16286 16286 2 17258 4624 17258 1 6686 6686 3 2512 4054 14301 2512 2 15777 9421 15777 1 5595 5595 1 66 4054 1 16803 4624 2 7556 8368 7556 6 14307 10979 671 17812 12473 14128 14307 1 18809 671 4 3307 17296 17791 11240 3307 8 15394 16768 8001 10823 7380 96...
result:
ok ok
Test #20:
score: 0
Accepted
time: 45ms
memory: 50072kb
input:
20000 499998 456 17380 3548 17148 12088 15694 2886 15042 15060 4903 3288 13810 5360 7487 15472 1934 6496 19753 7795 9485 16913 17980 18738 18003 3795 5186 18128 15284 3276 16833 13161 6707 8941 947 5088 4974 13222 1790 14903 14837 4315 17583 12119 15871 6961 11561 3674 18427 2207 1556 19736 719 2326...
output:
Yes 11845 20000 1 3756 3756 2 3952 16700 3952 2 10374 19993 10374 2 18183 17876 18183 3 12183 14472 6170 12183 2 15047 13069 15047 2 18525 8672 18525 1 13202 13202 1 2183 2183 3 9572 2734 11116 9572 1 16091 16091 2 4984 15803 4984 1 603 603 3 10334 15944 10789 10334 3 10312 12061 523 ...
result:
ok ok
Test #21:
score: 0
Accepted
time: 65ms
memory: 52316kb
input:
100000 500000 1235 3510 14575 57589 88714 29299 62839 6733 25039 17686 8112 24858 274 16916 83976 25181 57773 49758 65223 33663 47471 12200 8551 57927 21092 67375 77093 76589 91355 94075 17071 50791 43800 72672 54280 19504 106 10971 87577 40091 88380 81937 27327 24188 78489 92382 43581 8875 22402 41...
output:
No
result:
ok ok
Test #22:
score: 0
Accepted
time: 79ms
memory: 54560kb
input:
100000 500000 9 34008 13155 90342 28233 23089 86546 14071 6854 11360 3498 65486 65603 70184 14269 18649 79366 11163 66926 49216 4445 76420 50121 20493 2808 43301 18218 44910 92999 97448 13760 37138 15100 36649 34074 1879 72027 68411 54611 87760 1896 60316 43650 8286 34285 74403 21309 96104 49344 941...
output:
Yes 59677 100000 1 931 931 2 53903 21654 53903 1 99875 99875 2 43291 96416 43291 1 82157 82157 1 3153 3153 5 67452 66303 23279 23283 34388 67452 2 90473 73038 90473 2 53752 23674 23674 1 48871 48871 6 89807 94111 20471 31009 27663 10000 89807 1 29385 29385 1 52351 52351 1 84878 84878 4...
result:
ok ok
Test #23:
score: 0
Accepted
time: 83ms
memory: 54620kb
input:
100000 500000 1 75076 9583 32552 72566 77581 74823 25463 58197 78380 62002 94563 99622 60434 39479 68180 1722 38894 43269 85989 33777 78513 5464 79304 57968 37134 88958 60066 61043 23394 50002 93317 59516 46962 55978 3705 2504 341 70466 21789 42193 45686 1370 18780 91444 2274 93546 66571 97443 53551...
output:
Yes 59628 100000 3 76450 94576 61263 76450 2 47675 50108 47675 2 79523 63246 63246 6 82735 24959 4595 71896 53837 18496 82735 1 46922 46922 2 20437 23559 20437 1 4821 53837 2 98376 1374 98376 1 503 503 2 58984 32910 58984 4 54243 80337 41949 76931 41949 4 72337 31428 79102 92671 72337 1 ...
result:
ok ok
Test #24:
score: 0
Accepted
time: 95ms
memory: 54728kb
input:
100000 500000 0 39862 49976 22596 40406 37185 98022 80733 93561 81387 94842 25064 61254 42694 16911 22623 87861 89266 37654 59510 12230 43457 79569 73883 19406 63275 92754 22177 11799 5763 44974 1570 83476 79123 73330 45165 77314 63415 32676 70388 8398 22032 77785 63620 61574 23429 41486 30923 1236...
output:
Yes 59809 100000 3 69530 80512 53706 69530 4 14561 60825 24678 93228 14561 4 4385 39805 75476 85590 4385 2 27589 40371 27589 3 58681 4758 56008 4758 1 66718 66718 1 61541 61541 5 22666 96489 64330 9636 59258 22666 1 73798 73798 1 4388 96489 1 29402 29402 3 81884 22870 39842 81884 1 14824...
result:
ok ok
Test #25:
score: 0
Accepted
time: 55ms
memory: 53016kb
input:
199999 200000 10 162044 184301 102211 174303 129412 46215 153004 13679 113247 194319 100393 176945 52810 193834 159859 44467 119931 61763 196292 30856 21297 175055 20174 1882 11250 184866 74000 1054 74272 134956 41299 186242 162575 63218 119189 12678 29884 5001 148164 16567 24612 169902 77735 135002...
output:
No
result:
ok ok
Test #26:
score: 0
Accepted
time: 57ms
memory: 55796kb
input:
200000 199999 0 142790 145621 180161 104270 112230 88214 154000 63048 188285 141046 185739 50230 142683 197737 141276 49672 41219 95859 175530 171250 171226 174408 151297 88982 28928 71368 199034 63185 116370 106685 192890 167797 132366 79091 78160 89965 177169 151554 172583 127365 9032 60583 78786...
output:
No
result:
ok ok
Test #27:
score: 0
Accepted
time: 93ms
memory: 57312kb
input:
200000 500000 245 193722 185527 109052 75916 93935 24076 79627 20964 180786 120016 132778 186582 144529 16308 58727 114586 130490 34200 113593 7386 151039 39324 175706 195617 169880 139107 160903 183556 167931 124336 92216 181943 41472 98648 191217 191760 19769 86540 4125 65866 133876 106754 96372 1...
output:
No
result:
ok ok
Test #28:
score: 0
Accepted
time: 95ms
memory: 58236kb
input:
200000 500000 14 142703 65403 129451 151977 165363 20230 132897 87039 9024 158327 31353 194121 16577 146056 139648 187616 8050 35431 127655 35285 195736 80740 3874 174224 168938 136840 97592 176911 12210 58008 85816 66096 61709 179153 69540 1567 86595 14951 182066 29930 183615 37773 166329 61767 167...
output:
No
result:
ok ok
Test #29:
score: 0
Accepted
time: 141ms
memory: 64160kb
input:
200000 500000 1 5880 85775 146428 142622 151159 88421 138441 169300 66421 147351 32187 62008 74476 82579 109015 176101 15964 50525 172923 142682 150232 178015 197099 29910 154380 124900 65984 825 137825 194984 139256 31396 65802 141485 14608 126721 85235 193397 167129 98424 54611 63857 8244 68507 68...
output:
Yes 120468 200000 2 187862 176866 187862 1 110733 110733 3 114486 132702 163385 114486 1 61067 61067 1 34146 34146 1 100033 100033 2 191929 125042 191929 2 112941 36575 112941 1 15216 15216 6 59246 101423 36377 53601 69591 112933 101423 1 49033 53601 1 146193 146193 1 137088 112933 1 35...
result:
ok ok
Test #30:
score: 0
Accepted
time: 78ms
memory: 64304kb
input:
199999 199998 73589 144387 49530 75323 115971 116495 141238 92902 186288 75011 21274 196 62128 161581 112516 16226 166382 73692 120539 170346 127146 153896 57832 23870 56030 110186 132465 101619 681 13908 5901 194116 151154 160650 78720 87497 131676 94642 65227 153151 67720 61825 132140 114363 76085...
output:
Yes 126410 199998 2 199997 199999 199997 1 199995 199995 2 199993 199996 199993 2 199992 199994 199992 1 199991 199991 1 199988 199988 2 199986 199990 199986 1 199980 199980 2 199973 199985 199973 3 199964 199979 199981 199964 3 199959 199974 199972 199959 3 199954 199963 199962 199954 4...
result:
ok ok
Test #31:
score: 0
Accepted
time: 4ms
memory: 40800kb
input:
2 1 1 1 1 2
output:
Yes 1 2 1 1
result:
ok ok
Test #32:
score: 0
Accepted
time: 0ms
memory: 41732kb
input:
2 1 0 1 2
output:
Yes 1 2 1 1
result:
ok ok
Extra Test:
score: 0
Extra Test Passed