QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#441624 | #8531. A Graph Problem | arbuzick# | 17.391304 | 349ms | 3836kb | C++20 | 1.2kb | 2024-06-14 16:45:00 | 2024-06-14 16:45:01 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
constexpr int mod = 1e9 + 7;
void solve() {
int n, m;
cin >> n >> m;
vector<vector<pair<int, int>>> g(n);
for (int i = 0; i < m; ++i) {
int a, b;
cin >> a >> b;
a--, b--;
g[a].emplace_back(b, i + 1);
g[b].emplace_back(a, i + 1);
}
for (int i = 0; i < n; ++i) {
int ans = 0;
set<pair<int, int>> s;
vector<int> used(n);
used[i] = 1;
for (auto [j, ind] : g[i]) {
s.insert(make_pair(ind, j));
}
while (!s.empty()) {
auto p = *s.begin();
s.erase(s.begin());
if (used[p.second]) {
continue;
}
ans = (ans * 10LL + p.first) % mod;
used[p.second] = 1;
for (auto [j, ind] : g[p.second]) {
if (!used[j]) {
s.insert(make_pair(ind, j));
}
}
}
cout << ans << '\n';
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
return 0;
}
详细
Test #1:
score: 4.34783
Accepted
time: 1ms
memory: 3836kb
input:
3 2 1 2 2 3
output:
12 12 21
result:
ok 3 lines
Test #2:
score: 4.34783
Accepted
time: 0ms
memory: 3528kb
input:
5 6 1 2 3 4 2 4 2 3 2 5 1 5
output:
1325 1325 2315 2315 5132
result:
ok 5 lines
Test #3:
score: 4.34783
Accepted
time: 0ms
memory: 3576kb
input:
15 14 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15
output:
678925929 678925929 678862929 678787329 678709839 678632097 178554320 218476543 321398766 431520989 542453212 653475435 764507558 875540761 986574081
result:
ok 15 lines
Test #4:
score: 4.34783
Accepted
time: 349ms
memory: 3748kb
input:
1850 2000 535 1272 1182 1267 73 290 1339 1470 894 1137 784 1364 610 1619 800 1650 413 1524 906 1242 1262 1701 1311 1658 1317 1572 1129 1251 280 1777 1090 1189 101 250 1183 1647 494 1651 125 1327 734 806 160 454 1235 1473 594 1462 477 1653 1499 1564 101 150 532 1783 323 996 273 1660 673 1712 467 1336...
output:
549744152 65443958 947942184 206882269 294225986 509279775 607027484 831437377 284527138 644981110 136872723 346562272 805001638 757538080 142994739 636604032 235915153 191478222 420266891 316351348 160427563 981024549 295451063 206574440 169724015 998341320 504596619 257672157 680397426 92774892 71...
result:
ok 1850 lines
Test #5:
score: 0
Time Limit Exceeded
input:
2000 400000 241 1037 978 1342 9 64 31 1222 483 665 176 581 1145 1835 1009 1936 537 1738 262 1732 392 1222 980 1718 97 1196 308 718 1631 1889 1030 1135 699 906 1023 1910 559 1724 665 1147 802 1614 1463 1557 1316 1957 947 1045 149 1609 347 732 56 1061 785 869 1250 1944 1383 1925 354 1073 831 1760 1534...
output:
result:
Test #6:
score: 0
Time Limit Exceeded
input:
2000 400000 1048 1063 489 1920 501 736 126 227 180 966 888 1730 805 1772 910 1378 1228 1779 1209 1668 858 1055 1441 1667 1669 1768 1422 1838 377 609 405 725 241 1865 1591 1630 60 958 842 1905 730 1585 525 1217 542 558 223 379 111 1100 55 58 279 1227 1575 1897 1064 1141 1486 1533 118 1114 273 1802 10...
output:
result:
Test #7:
score: 0
Time Limit Exceeded
input:
10000 400000 778 2359 1787 3580 8076 8697 1493 4885 814 5277 6198 8246 5055 6524 2577 3582 2255 5344 3106 3900 3091 7388 342 1489 1526 1578 780 797 1508 7293 1706 5591 1164 1891 2995 8016 858 9774 671 929 2899 7410 5487 9875 3550 9116 2498 9714 129 5909 81 9810 4951 8871 2138 5523 5182 6919 7544 883...
output:
result:
Test #8:
score: 0
Time Limit Exceeded
input:
10000 400000 2990 6494 3213 8324 4148 9810 2321 6780 2887 5978 7186 7772 1435 7364 3345 4004 3916 6828 9566 9643 1363 2996 3515 8342 2790 6713 5966 9814 7748 7847 5730 6344 6782 8035 6962 9136 4092 7456 1053 7773 6298 8474 1037 6022 1292 3965 3396 9610 3585 9769 7463 8127 1815 2443 100 8984 1595 373...
output:
result:
Test #9:
score: 0
Time Limit Exceeded
input:
10000 400000 9197 9788 102 839 1143 5723 3554 4275 3868 9539 771 6032 3553 9453 371 4184 207 5903 849 6720 1139 6924 4014 4567 4841 8626 9890 9922 2021 3345 669 7509 2799 5842 6817 8841 2893 9707 1205 4562 1890 4998 3513 3766 4296 9439 2714 5367 5833 6209 3437 8536 5262 5992 6211 9487 5293 7654 5407...
output:
result:
Test #10:
score: 0
Time Limit Exceeded
input:
10000 400000 2674 2998 5213 9617 2470 4209 1527 8263 2494 6282 1447 7812 8231 8955 4117 9882 931 7152 4191 9268 5231 5650 235 6429 1950 3881 1366 5777 9020 9644 4884 9024 3972 9852 4581 5252 1683 6740 1466 5774 2931 3731 2549 4118 6783 9068 2707 8726 4902 8947 1306 4288 2835 4072 4512 9282 592 6080 ...
output:
result:
Test #11:
score: 0
Time Limit Exceeded
input:
200000 199999 7451 7452 7452 7453 7453 7454 7454 7455 7455 7456 7456 7457 7457 7458 7458 7459 7459 7460 7460 7461 7461 7462 7462 7463 7463 7464 7464 7465 7465 7466 7466 7467 7467 7468 7468 7469 7469 7470 7470 7471 7471 7472 7472 7473 7473 7474 7474 7475 7475 7476 7476 7477 7477 7478 7478 7479 7479 7...
output:
result:
Test #12:
score: 0
Time Limit Exceeded
input:
200000 199999 63667 63668 63666 63667 63665 63666 63664 63665 63663 63664 63662 63663 63661 63662 63660 63661 63659 63660 63658 63659 63657 63658 63656 63657 63655 63656 63654 63655 63653 63654 63652 63653 63651 63652 63650 63651 63649 63650 63648 63649 63647 63648 63646 63647 63645 63646 63644 6364...
output:
result:
Test #13:
score: 0
Time Limit Exceeded
input:
200000 199999 67602 67603 67603 67604 67604 67605 67605 67606 67606 67607 67607 67608 67608 67609 67609 67610 67610 67611 67611 67612 67612 67613 67613 67614 67614 67615 67615 67616 67616 67617 67617 67618 67618 67619 67619 67620 67620 67621 67621 67622 67622 67623 67623 67624 67624 67625 67625 6762...
output:
result:
Test #14:
score: 0
Time Limit Exceeded
input:
200000 199999 2337 2338 2338 2339 2339 2340 2340 2341 2341 2342 2342 2343 2343 2344 2344 2345 2345 2346 2346 2347 2347 2348 2348 2349 2349 2350 2350 2351 2351 2352 2352 2353 2353 2354 2354 2355 2355 2356 2356 2357 2357 2358 2358 2359 2359 2360 2360 2361 2361 2362 2362 2363 2363 2364 2364 2365 2365 2...
output:
result:
Test #15:
score: 0
Time Limit Exceeded
input:
200000 400000 69354 168457 53989 75309 167264 182311 66623 153345 78557 193855 39834 44704 9200 79045 43416 65994 4303 34947 8935 189925 6103 89459 101253 157016 45650 184018 35685 75748 15843 125556 19443 45770 113826 149007 44321 105930 40005 147158 29900 135638 94100 128382 100444 146374 32168 10...
output:
result:
Test #16:
score: 0
Time Limit Exceeded
input:
200000 400000 138624 188139 79804 145333 51034 64229 30009 168087 6271 37660 147448 199738 23702 134452 28418 168836 39386 69950 84025 161110 17532 18064 27783 55968 20187 168760 118383 199140 102438 157309 118681 195228 159214 169861 32061 38787 60647 116055 20433 90598 28807 92771 172240 192922 63...
output:
result:
Test #17:
score: 0
Time Limit Exceeded
input:
200000 400000 34810 153024 35972 190888 59728 185676 166424 184755 27926 163241 28534 65646 101912 147390 29823 92536 84139 146163 152112 166895 113960 168126 29948 56097 45071 130904 19325 181534 31189 104284 162661 182196 71097 74296 149370 167685 59342 70987 39270 171441 97471 148464 85624 103938...
output:
result:
Test #18:
score: 0
Time Limit Exceeded
input:
200000 400000 35062 73649 64791 143925 101462 165038 45693 153331 35409 107285 115961 145427 27783 67918 128531 145779 40834 199992 6065 6545 82539 134077 98906 185742 98690 194487 2224 50027 64160 75915 60576 191737 12703 75305 688 121173 88951 169823 54264 175492 133505 147184 4763 122735 125764 1...
output:
result:
Test #19:
score: 0
Time Limit Exceeded
input:
200000 400000 69557 165536 76893 85294 93444 103801 29994 156596 29213 189223 69458 153440 74841 146861 29704 188158 93014 94262 54121 109853 21949 175512 40057 110336 75221 140758 72007 101575 63144 143155 3684 33946 64171 154358 40445 165178 126511 193846 83335 148593 13665 189586 88155 88304 6597...
output:
result:
Test #20:
score: 0
Time Limit Exceeded
input:
200000 400000 28718 41339 54122 85143 3679 8439 18874 46011 25879 171685 121889 144440 108371 156983 28028 98211 40126 189724 42583 159032 164412 187758 63293 91419 68633 141485 89943 102221 27494 35556 51414 117816 36855 56519 117586 160276 73971 140740 48995 112286 8979 197943 123524 193900 39752 ...
output:
result:
Test #21:
score: 0
Time Limit Exceeded
input:
200000 400000 11002 138561 94075 162193 143010 159774 26390 37531 31488 105313 8964 172286 2817 77514 100811 164684 157292 161979 7253 85764 25478 92507 47628 57195 8862 184895 18776 187888 10464 133759 81742 121864 36414 156894 22325 166702 63650 76310 152860 157752 105260 153534 6695 199012 5335 1...
output:
result:
Test #22:
score: 0
Time Limit Exceeded
input:
200000 400000 84237 117430 19258 38279 44815 191998 118424 176164 15893 49383 30974 187447 35089 172696 30293 147182 51323 181825 49658 148610 84750 105002 34271 62542 43135 119118 45822 195660 84354 191883 24867 191111 154041 198116 42634 45892 16524 91048 9018 60261 50462 61258 55036 83529 82217 1...
output:
result:
Test #23:
score: 0
Time Limit Exceeded
input:
200000 400000 24562 95258 68424 125123 67323 79526 88909 98334 98895 197405 12362 62753 139962 183338 41159 87038 61475 164241 107557 112478 37443 39227 64899 192102 27380 148780 35258 55995 127415 129946 119755 157839 48585 164932 11086 131612 119792 152566 39792 197004 6593 68750 60413 183111 1122...