QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#690908 | #9525. Welcome to Join the Online Meeting! | ucup-team1113 | AC ✓ | 172ms | 34836kb | C++17 | 2.1kb | 2024-10-31 08:24:05 | 2024-10-31 08:24:05 |
Judging History
answer
#include <bits/stdc++.h>
#define endl '\n'
using ll = long long;
constexpr int N = 2e5 + 10;
constexpr int mod = 998244353;
using namespace std;
void solve(){
int n, m, k;
cin >> n >> m >> k;
vector<int> f(n + 1), busy(n + 1);
iota(f.begin(), f.end(), 0);
auto find = [&](auto self, int x) -> int {
if (x == f[x]) return x;
return f[x] = self(self, f[x]);
};
for (int i = 1; i <= k; ++i) {
int x;
cin >> x;
busy[x] = 1;
}
for (int i = 1; i <= n; ++i) f[i] = i;
vector<vector<int>> E(n + 1), G(n + 1);
vector<int> fa(n + 1);
for (int i = 1; i <= m; ++i) {
int u, v;
cin >> u >> v;
if (busy[u] && busy[v]) continue;
if (busy[u]) {
if (fa[u]) continue;
fa[u] = 1;
E[v].push_back(u);
}else if (busy[v]) {
if (fa[v]) continue;
fa[v] = 1;
E[u].push_back(v);
}else {
int fu = find(find, u), fv = find(find, v);
if (fu != fv) {
f[fu] = fv;
}
G[u].push_back(v);
G[v].push_back(u);
}
}
int cnt = 0, rt;
for (int i = 1; i <= n; ++i) {
if (busy[i]) {
if (!fa[i]) {
cout << "No" << endl;
return;
}
}else {
if (find(find, i) != i) continue;
++cnt;
rt = i;
}
}
if (cnt != 1) {
cout << "No" << endl;
return;
}
vector<vector<int>> res;
queue<int> q;
vector<int> vis(n + 1);
q.push(rt);
vis[rt] = 1;
while (!q.empty()) {
auto x = q.front();
q.pop();
vector<int> cur;
for (auto y : E[x]) {
cur.push_back(y);
}
for (auto y : G[x]) {
if (vis[y]) continue;
vis[y] = 1;
q.push(y);
cur.push_back(y);
}
if (cur.empty()) continue;
cur.push_back(cur.size());
cur.push_back(x);
reverse(cur.begin(), cur.end());
res.push_back(cur);
}
cout << "Yes" << endl;
cout << (int)res.size() << endl;
for (auto v : res) {
for (auto x : v) {
cout << x << " ";
}
cout << endl;
}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
//cin >> t;
while(t--) solve();
return 0;
}
/*
4 5 3
2 4 3
1 2
1 3
2 3
3 4
2 4
*/
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3784kb
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: 0ms
memory: 3784kb
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: 3812kb
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 4 3
result:
ok ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 3556kb
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: 92ms
memory: 34768kb
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 186051 2 42967 142330 42967 1 107050 107050 1 159920 159920 1 187359 187359 1 111774 111774 1 4643 4643 1 22162 22162 1 119911 119911 1 165259 165259 1 80747 80747 1 145111 145111 1 99600 99600 1 157336 157336 1 31914 31914 1 158722 158722 1 154002 154002 1 156794 156794 ...
result:
ok ok
Test #6:
score: 0
Accepted
time: 91ms
memory: 34836kb
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 57897 2 67051 136702 67051 1 46188 46188 1 7309 7309 1 13560 13560 1 129012 129012 1 194652 194652 1 16855 16855 1 2643 2643 1 11843 11843 1 121085 121085 1 196582 196582 1 193681 193681 1 25576 25576 1 37117 37117 1 24236 24236 1 22598 22598 1 20647 20647 1 22635 22635 ...
result:
ok ok
Test #7:
score: 0
Accepted
time: 90ms
memory: 33968kb
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 199997 108040 1 162420 162420 1 130135 130135 1 168898 168898 1 4125 4125 1 67434 67434 1 132013 132013 1 36554 36554 1 114001 114001 1 171315 171315 1 14656 14656 1 37474 37474 1 46087 46087 1 66480 66480 1 161076 161076 1 103822 103822 1 131635 131635 1 148656 148656 1 136590 ...
result:
ok ok
Test #8:
score: 0
Accepted
time: 40ms
memory: 21852kb
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: 23ms
memory: 14884kb
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: 36ms
memory: 26180kb
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 152191 1 66864 66864 199997 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 5888...
result:
ok ok
Test #11:
score: 0
Accepted
time: 46ms
memory: 25672kb
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 108040 1 77056 77056 199996 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 111196 ...
result:
ok ok
Test #12:
score: 0
Accepted
time: 34ms
memory: 3908kb
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: 0
Accepted
time: 38ms
memory: 4012kb
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 227 663 238 646 189 945 461 510 144 174 861 499 74 948 746 975 67 260 477 889 94 333 465 991 989 387 86 582 596 472 509 613 195 915 752 183 805 22 984 494 20 708 1 505 217 599 297 210 373 938 756 169 271 248 830 389 667 576 60 798 911 44 871 127 268 847 537 352 604 804 840 489 710 412 2 588 453 ...
result:
ok ok
Test #14:
score: 0
Accepted
time: 26ms
memory: 7268kb
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 99 602 540 243 750 237 921 909 453 324 972 395 510 245 435 789 392 184 668 553 852 183 793 941 901 781 629 406 297 791 326 518 811 993 716 568 583 440 825 562 955 165 389 110 883 144 140 375 274 918 773 563 976 579 382 98 828 720 85 774 641 470 983 710 450 698 119 70 928 670 489 746 721 479 62 5...
result:
ok ok
Test #15:
score: 0
Accepted
time: 31ms
memory: 4040kb
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: 39ms
memory: 3940kb
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: 53ms
memory: 9212kb
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 1574 501 85 4295 5534 1290 9014 6636 6098 6387 8583 1545 2906 6977 9789 8771 4609 9976 8738 1760 7065 1168 7424 7686 9224 9922 7750 1988 2729 3620 2290 4761 6179 3537 766 4462 470 4937 6783 7092 4707 640 5744 8399 1096 2395 8558 809 6646 1849 9412 8398 8006 6397 5369 1941 2098 8073 6157 2876 695...
result:
ok ok
Test #18:
score: 0
Accepted
time: 53ms
memory: 9740kb
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 503 5694 95 2419 9226 7723 8544 3548 1300 3890 4662 9850 2541 4303 12 2401 3514 4783 2704 6303 2964 6864 9181 3396 38 302 3101 9954 2380 8459 2583 3549 8353 3096 2369 4428 2793 137 4510 4305 1547 8915 9059 9493 2823 1898 9972 1614 3770 1049 2678 3121 4608 7294 8542 8849 6823 6941 9189 2426 1106 ...
result:
ok ok
Test #19:
score: 0
Accepted
time: 76ms
memory: 10924kb
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 2126 2832 48 1348 17405 11065 13826 14976 11674 8834 8958 729 1885 1022 15932 6729 6090 9517 5492 9088 7766 11407 7338 17217 2698 10341 1210 11004 18388 4708 11720 10377 2266 865 6902 19283 15788 210 1703 19762 11304 13077 3455 17124 712 7715 3614 1123 1282 16863 16835 16835 56 3572 16548 19917...
result:
ok ok
Test #20:
score: 0
Accepted
time: 72ms
memory: 10632kb
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 2239 8744 43 10662 976 2311 4635 16440 14232 17079 11912 11188 3442 11722 9078 11094 16254 707 10708 8771 12815 15392 8968 17645 7545 16313 5026 6402 12244 10341 5673 961 15808 5596 17298 16096 8460 9023 10449 3224 5046 3544 2100 8901 15009 16061 16061 35 1331 12885 2480 10968 19659 11683 12232...
result:
ok ok
Test #21:
score: 0
Accepted
time: 97ms
memory: 17192kb
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: 117ms
memory: 18560kb
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 28804 51972 1 9158 9158 10 62258 65015 65143 47055 88432 39276 96087 98930 6031 5183 5183 13 59211 64546 21274 65829 3680 94011 73567 76242 66139 69686 15949 63446 75668 6031 8 50144 81643 24180 29938 38002 77539 23210 62954 98930 13 25138 77099 96805 97678 63007 1641 70099 67257 25105 69012...
result:
ok ok
Test #23:
score: 0
Accepted
time: 120ms
memory: 18476kb
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 28663 1504 2 93302 47016 47016 8 48222 29479 85062 50687 66744 22893 8314 82670 93302 8 54057 80357 79725 9448 11526 85995 88686 16497 82670 11 46709 56532 33181 59006 52729 83408 85398 43 17807 53437 43086 8314 10 64036 30 51441 11903 97767 98812 7274 12816 56888 87700 22893 10 25240 43096...
result:
ok ok
Test #24:
score: 0
Accepted
time: 101ms
memory: 18628kb
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 28725 76577 4 13000 84962 74672 52478 52478 6 61735 9893 17407 47733 51297 91680 74672 8 62191 65226 11457 97307 32067 81801 1916 98511 84962 7 59131 62194 48766 31157 13644 2314 26588 13000 11 8007 63596 66241 83512 42173 31274 60813 92048 40366 19868 52810 91680 6 62680 26752 42216 13916 ...
result:
ok ok
Test #25:
score: 0
Accepted
time: 46ms
memory: 21192kb
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: 41ms
memory: 21176kb
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: 126ms
memory: 24628kb
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: 123ms
memory: 24556kb
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: 172ms
memory: 31312kb
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 87320 116703 1 140836 140836 2 62556 107328 107328 6 192845 185902 49580 159857 199578 55220 62556 5 80371 182588 4112 58994 73288 55220 5 5168 146968 198476 128399 148136 199578 7 129985 129224 172376 151255 45014 118582 108283 159857 6 103145 128657 164824 140348 145985 43190 49580 5 79...
result:
ok ok
Test #30:
score: 0
Accepted
time: 85ms
memory: 28508kb
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 82797 4 82275 83318 83316 83317 82275 3 81723 82798 82799 82798 1 83319 81723 2 82274 81156 83319 1 83831 81156 1 80602 82274 3 82796 82795 82794 80602 1 80064 82795 1 83314 82796 1 83315 80064 3 80603 79534 80601 83314 1 83830 79534 1 78996 80603 1 81157 78996 2 78423 79533...
result:
ok ok
Test #31:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
2 1 1 1 1 2
output:
Yes 1 2 1 1
result:
ok ok
Test #32:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
2 1 0 1 2
output:
Yes 1 2 1 1
result:
ok ok
Extra Test:
score: 0
Extra Test Passed