QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#716425 | #9525. Welcome to Join the Online Meeting! | guanghere | WA | 86ms | 36960kb | C++23 | 2.2kb | 2024-11-06 15:14:49 | 2024-11-06 15:14:50 |
Judging History
answer
//
// Created by 24087 on 24-11-5.
//
#include <iostream>
#include <numeric>
#include <queue>
#include <vector>
int n, m, k;
std::vector<std::vector<int>> g;
std::vector<std::vector<int>> tmp;
std::vector<bool> vis;
void dfs(int now, int dep) {
vis[now] = true;
for (auto &v : g[now]) {
if (vis[v]) continue;
tmp[now].push_back(v);
dfs(v, dep + 1);
}
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
std::cin >> n >> m >> k;
g.resize(n + 1); // u->v表示u能够邀请v
tmp.resize(n + 1);
vis.resize(n + 1);
std::vector<bool> busy(n + 1);
for (int i = 1, pos; i <= k; i++) {
std::cin >> pos;
busy[pos] = true;
} // 如果busy[i]为true,g[i] = {}
for (int i = 1, u, v; i <= m; i++) {
std::cin >> u >> v;
if (!busy[u]) {
g[u].push_back(v);
}
if (!busy[v]) {
g[v].push_back(u);
}
}
for (int i = 1; i <= n; i++) {
if (!busy[i]) {
dfs(i, 1);
if (std::accumulate(vis.begin(), vis.end(), 0) == n) {
std::cout << "Yes\n"
<< std::accumulate(
tmp.begin(), tmp.end(), 0,
[](int sum, const std::vector<int> &v) {
return sum + !v.empty();
})
<< '\n';
std::queue<int> q;
q.push(i);
while (!q.empty()) {
int now = q.front();
q.pop();
if (tmp[now].empty()) {
continue;
}
std::cout << now << ' ' << tmp[now].size() << ' ';
for (auto &v : tmp[now]) {
std::cout << v << ' ';
q.push(v);
}
std::cout << '\n';
}
} else {
std::cout << "No\n";
}
return 0;
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3600kb
input:
4 5 2 3 4 1 2 1 3 2 3 3 4 2 4
output:
Yes 2 1 1 2 2 2 3 4
result:
ok ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3552kb
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: 3784kb
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: 3824kb
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: 83ms
memory: 36960kb
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: 86ms
memory: 36104kb
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: 0
Accepted
time: 83ms
memory: 36436kb
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:
ok ok
Test #8:
score: 0
Accepted
time: 46ms
memory: 32508kb
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: 28ms
memory: 18696kb
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: 39ms
memory: 21220kb
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 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 3648...
result:
ok ok
Test #11:
score: 0
Accepted
time: 44ms
memory: 21352kb
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 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 3315 1...
result:
ok ok
Test #12:
score: 0
Accepted
time: 35ms
memory: 3600kb
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 516 5 990 603 581 613 664 339 669 702 571 159 399 397 347 481 43 709 916 191 33 517 178 751 897 868 687 155 993 78 378 865 108 677 382 158 937 496 4 541 398 367 237 825 364 518 679 578 199 566 180 894 275 273 305 805 933 524 30 576 707 437 38 513 762 56 349 785 186 461 15 44 991 366 42...
result:
ok ok
Test #13:
score: 0
Accepted
time: 40ms
memory: 4372kb
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 235 1 8 241 545 810 270 530 700 627 859 859 6 671 881 253 372 981 492 492 5 6 856 918 738 7 7 1 800 800 5 157 436 246 193 260 260 1 51 51 3 891 839 532 532 3 331 321 494 494 3 487 263 121 121 2 404 945 945 5 104 850 173 305 474 474 7 733 259 909 529 725 286 499 499 1 807 807 1 599 ...
result:
ok ok
Test #14:
score: 0
Accepted
time: 26ms
memory: 7460kb
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 899 1 1 249 249 1 302 302 2 839 618 618 1 919 919 1 243 243 2 367 440 440 1 636 636 1 70 70 1 973 973 1 86 86 1 887 887 2 170 127 127 1 721 721 1 92 92 1 619 619 1 507 507 1 205 205 2 824 181 181 1 418 418 1 318 318 1 239 239 1 981 981 3 722 845 398 398 1 351 351 1 464 4...
result:
ok ok
Test #15:
score: -100
Wrong Answer
time: 40ms
memory: 3556kb
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:
result:
wrong output format Unexpected end of file - token expected