| Task: | Stations |
| Sender: | adex720 |
| Submission time: | 2025-03-03 17:56:17 +0200 |
| Language: | C++ (C++20) |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | RUNTIME ERROR | 0 |
| #2 | WRONG ANSWER | 0 |
| #3 | WRONG ANSWER | 0 |
| #4 | WRONG ANSWER | 0 |
| #5 | WRONG ANSWER | 0 |
| #6 | RUNTIME ERROR | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | RUNTIME ERROR | 0.00 s | 1, 6 | details |
| #2 | RUNTIME ERROR | 0.00 s | 1, 6 | details |
| #3 | RUNTIME ERROR | 0.00 s | 1, 6 | details |
| #4 | ACCEPTED | 0.00 s | 1, 3, 6 | details |
| #5 | ACCEPTED | 0.01 s | 1, 3, 6 | details |
| #6 | ACCEPTED | 0.00 s | 1, 3, 6 | details |
| #7 | RUNTIME ERROR | 0.00 s | 1, 6 | details |
| #8 | RUNTIME ERROR | 0.00 s | 1, 6 | details |
| #9 | RUNTIME ERROR | 0.00 s | 1, 6 | details |
| #10 | RUNTIME ERROR | 0.00 s | 1, 6 | details |
| #11 | RUNTIME ERROR | 0.00 s | 1, 6 | details |
| #12 | RUNTIME ERROR | 0.01 s | 1, 6 | details |
| #13 | ACCEPTED | 0.00 s | 1, 2, 3, 4, 5, 6 | details |
| #14 | WRONG ANSWER | 0.06 s | 2, 3, 4, 5, 6 | details |
| #15 | WRONG ANSWER | 0.07 s | 3, 6 | details |
| #16 | TIME LIMIT EXCEEDED | -- | 3, 6 | details |
| #17 | RUNTIME ERROR | 0.04 s | 4, 5, 6 | details |
| #18 | WRONG ANSWER | 0.07 s | 3, 4, 5, 6 | details |
| #19 | TIME LIMIT EXCEEDED | -- | 3, 4, 5, 6 | details |
| #20 | ACCEPTED | 0.00 s | 1, 3, 4, 5, 6 | details |
| #21 | RUNTIME ERROR | 0.04 s | 4, 5, 6 | details |
| #22 | RUNTIME ERROR | 0.04 s | 4, 5, 6 | details |
| #23 | RUNTIME ERROR | 0.04 s | 4, 5, 6 | details |
| #24 | RUNTIME ERROR | 0.04 s | 5, 6 | details |
| #25 | RUNTIME ERROR | 0.04 s | 5, 6 | details |
| #26 | RUNTIME ERROR | 0.04 s | 5, 6 | details |
| #27 | RUNTIME ERROR | 0.04 s | 5, 6 | details |
| #28 | RUNTIME ERROR | 0.04 s | 5, 6 | details |
| #29 | RUNTIME ERROR | 0.04 s | 5, 6 | details |
| #30 | RUNTIME ERROR | 0.03 s | 5, 6 | details |
| #31 | RUNTIME ERROR | 0.04 s | 6 | details |
| #32 | RUNTIME ERROR | 0.04 s | 6 | details |
| #33 | RUNTIME ERROR | 0.05 s | 6 | details |
| #34 | RUNTIME ERROR | 0.04 s | 6 | details |
| #35 | RUNTIME ERROR | 0.04 s | 6 | details |
| #36 | RUNTIME ERROR | 0.05 s | 6 | details |
| #37 | RUNTIME ERROR | 0.04 s | 6 | details |
| #38 | RUNTIME ERROR | 0.04 s | 6 | details |
Code
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, k, a, b, c;
cin >> n >> k;
vector<pair<int, int>> yhteydet[n];
for (int i = 1; i < n; i++)
{
cin >> a >> b >> c;
yhteydet[a].push_back({b, c});
yhteydet[b].push_back({a, c});
}
a = -1;
b = -1;
for (int i = 0; i < n; i++)
{
if (yhteydet[i].size() > 1)
continue;
if (a == -1)
a = i;
else
b = i;
}
ll maarat[n];
for (int i = 0; i < n; i++)
{
maarat[i] = 0ll;
}
for (int sdfgs = 1; sdfgs <= 2; sdfgs++)
{
vector<tuple<int, int, int>> edelliset;
queue<tuple<int, int, int>> seuraavat;
int e = -1;
int edellinen = sdfgs == 1 ? a : b;
int uusia = n;
while (true)
{
uusia--;
auto s = yhteydet[edellinen].at(0);
int seuraava = s.first;
if (seuraava == e)
{
s = yhteydet[edellinen].at(1);
seuraava = s.first;
}
int pituus = s.second;
int tankkauksia = 0;
int tuloja = 0;
for (auto u : edelliset)
{
int maara = get<0>(u);
int jaljella = get<1>(u);
int poistuu = get<2>(u);
if (jaljella >= pituus)
{
seuraavat.push({maara - poistuu, jaljella - pituus, poistuu});
}
else
{
tankkauksia += maara - poistuu;
tuloja += poistuu;
}
}
maarat[edellinen] += tankkauksia;
seuraavat.push({tankkauksia + uusia, k - pituus, tuloja + 1});
if (seuraava == (sdfgs == 1 ? b : a))
break;
e = edellinen;
edellinen = seuraava;
edelliset.clear();
while (!seuraavat.empty())
{
edelliset.push_back(seuraavat.front());
seuraavat.pop();
}
}
}
for (int i : maarat)
{
cout << i << "\n";
}
}
/*
10 18
1 0 6
1 2 1
2 3 4
3 4 9
4 5 5
5 6 3
6 7 8
7 8 7
8 9 2
*/Test details
Test 1
Group: 1, 6
Verdict: RUNTIME ERROR
| input |
|---|
| 750 918 159 63 18 573 310 105 135 400 57 618 27 113 ... |
| correct output |
|---|
| 0 96 45 94 0 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_r...
Test 2
Group: 1, 6
Verdict: RUNTIME ERROR
| input |
|---|
| 967 334 285 176 1 648 431 1 493 893 2 261 165 1 ... |
| correct output |
|---|
| 0 0 0 0 0 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_r...
Test 3
Group: 1, 6
Verdict: RUNTIME ERROR
| input |
|---|
| 1000 963 408 385 876 23 519 951 649 232 605 821 385 792 ... |
| correct output |
|---|
| 0 0 482612 0 912 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_r...
Test 4
Group: 1, 3, 6
Verdict: ACCEPTED
| input |
|---|
| 1000 396 412 257 190 290 965 25 399 938 174 980 459 117 ... |
| correct output |
|---|
| 215160 138947 196491 47632 103775 ... |
| user output |
|---|
| 215160 138947 196491 47632 103775 ... Truncated |
Test 5
Group: 1, 3, 6
Verdict: ACCEPTED
| input |
|---|
| 1000 333 896 853 0 28 756 0 658 183 0 488 17 0 ... |
| correct output |
|---|
| 0 0 0 0 0 ... |
| user output |
|---|
| 0 0 0 0 0 ... Truncated |
Test 6
Group: 1, 3, 6
Verdict: ACCEPTED
| input |
|---|
| 2 31 0 1 31 |
| correct output |
|---|
| 0 0 |
| user output |
|---|
| 0 0 |
Test 7
Group: 1, 6
Verdict: RUNTIME ERROR
| input |
|---|
| 1000 847 24 298 474 208 141 485 789 89 60 1 809 437 ... |
| correct output |
|---|
| 16 1080 1966 5980 1856 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_r...
Test 8
Group: 1, 6
Verdict: RUNTIME ERROR
| input |
|---|
| 1000 767 476 799 361 271 239 215 447 941 269 219 664 600 ... |
| correct output |
|---|
| 1017 997 3988 1996 0 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_r...
Test 9
Group: 1, 6
Verdict: RUNTIME ERROR
| input |
|---|
| 1000 1000 574 351 479 444 634 559 531 70 113 180 828 194 ... |
| correct output |
|---|
| 17839 4922 3988 0 0 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_r...
Test 10
Group: 1, 6
Verdict: RUNTIME ERROR
| input |
|---|
| 1000 1000 680 881 340 73 368 929 303 239 219 861 605 561 ... |
| correct output |
|---|
| 88 3990 9954 0 0 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_r...
Test 11
Group: 1, 6
Verdict: RUNTIME ERROR
| input |
|---|
| 1000 1000 164 378 963 934 141 358 866 915 598 341 220 55 ... |
| correct output |
|---|
| 1996 0 1147 1996 18739 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_r...
Test 12
Group: 1, 6
Verdict: RUNTIME ERROR
| input |
|---|
| 1000 537 276 155 470 533 155 391 175 155 343 553 155 270 ... |
| correct output |
|---|
| 0 0 0 0 0 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_r...
Test 13
Group: 1, 2, 3, 4, 5, 6
Verdict: ACCEPTED
| input |
|---|
| 2 1 0 1 1 |
| correct output |
|---|
| 0 0 |
| user output |
|---|
| 0 0 |
Test 14
Group: 2, 3, 4, 5, 6
Verdict: WRONG ANSWER
| input |
|---|
| 70000 1 50913 18377 1 33894 11911 1 61940 7863 1 61602 33470 1 ... |
| correct output |
|---|
| 2128187656 1918647796 1539693556 1198079316 2227641388 ... |
| user output |
|---|
| 2128187656 1918647796 1539693556 1198079316 -2067325908 ... Truncated |
Test 15
Group: 3, 6
Verdict: WRONG ANSWER
| input |
|---|
| 70000 517272873 57335 18148 62837135 28239 56484 253183094 23004 59130 129215861 558 17489 52424960 ... |
| correct output |
|---|
| 450859 215263283 544492560 222149 1276050 ... |
| user output |
|---|
| 450859 215263283 544492560 222149 1276050 ... Truncated |
Test 16
Group: 3, 6
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 70000 611016790 21272 16063 50360 30758 33429 30642 23317 5625 9045 66335 5731 24130 ... |
| correct output |
|---|
| 69999 102210 23584 30220 0 ... |
| user output |
|---|
| (empty) |
Test 17
Group: 4, 5, 6
Verdict: RUNTIME ERROR
| input |
|---|
| 69973 4 44281 27162 1 15299 61302 1 19250 66379 1 45970 65938 1 ... |
| correct output |
|---|
| 769608 34960 1162375 626228 2 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_r...
Test 18
Group: 3, 4, 5, 6
Verdict: WRONG ANSWER
| input |
|---|
| 70000 6 12580 20937 2 31244 33335 1 62095 66946 0 2558 64306 2 ... |
| correct output |
|---|
| 95678 275287413 81937227 47960445 176569 ... |
| user output |
|---|
| 95678 275287413 81937227 47960445 176569 ... Truncated |
Test 19
Group: 3, 4, 5, 6
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 70000 10 45546 20793 0 44801 49720 0 54732 9736 0 64375 18647 0 ... |
| correct output |
|---|
| 0 0 0 0 0 ... |
| user output |
|---|
| (empty) |
Test 20
Group: 1, 3, 4, 5, 6
Verdict: ACCEPTED
| input |
|---|
| 2 6 0 1 6 |
| correct output |
|---|
| 0 0 |
| user output |
|---|
| 0 0 |
Test 21
Group: 4, 5, 6
Verdict: RUNTIME ERROR
| input |
|---|
| 70000 10 36906 67900 2 51465 24882 0 65531 32406 0 49018 50640 10 ... |
| correct output |
|---|
| 0 0 1141061037 69997 0 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_r...
Test 22
Group: 4, 5, 6
Verdict: RUNTIME ERROR
| input |
|---|
| 70000 10 40966 26929 6 15381 7596 3 53090 61576 3 6976 65087 2 ... |
| correct output |
|---|
| 279988 0 0 56174160 0 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_r...
Test 23
Group: 4, 5, 6
Verdict: RUNTIME ERROR
| input |
|---|
| 70000 10 47111 32841 10 510 5994 10 1362 44478 8 61688 30984 5 ... |
| correct output |
|---|
| 419980 0 979765 0 1679710 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_r...
Test 24
Group: 5, 6
Verdict: RUNTIME ERROR
| input |
|---|
| 70000 7 12257 45873 7 53771 24407 7 67182 59338 2 68981 59097 6 ... |
| correct output |
|---|
| 0 0 0 0 56749 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_r...
Test 25
Group: 5, 6
Verdict: RUNTIME ERROR
| input |
|---|
| 70000 7 60987 29710 2 40235 14667 3 49803 36218 0 1256 23603 0 ... |
| correct output |
|---|
| 559942 0 69996 0 0 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_r...
Test 26
Group: 5, 6
Verdict: RUNTIME ERROR
| input |
|---|
| 70000 4 29827 12474 3 52717 68608 1 26411 5022 3 66140 68360 2 ... |
| correct output |
|---|
| 419970 0 0 202 0 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_r...
Test 27
Group: 5, 6
Verdict: RUNTIME ERROR
| input |
|---|
| 70000 10 41642 65096 7 14235 28073 6 48132 705 7 23384 33897 0 ... |
| correct output |
|---|
| 139996 279988 0 0 0 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_r...
Test 28
Group: 5, 6
Verdict: RUNTIME ERROR
| input |
|---|
| 70000 10 44002 46661 10 16351 40057 10 62342 69569 2 277 38372 1 ... |
| correct output |
|---|
| 0 0 559966 0 0 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_r...
Test 29
Group: 5, 6
Verdict: RUNTIME ERROR
| input |
|---|
| 70000 10 11173 32861 3 13926 50906 10 18305 60850 3 13279 836 9 ... |
| correct output |
|---|
| 0 139996 2 0 0 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_r...
Test 30
Group: 5, 6
Verdict: RUNTIME ERROR
| input |
|---|
| 70000 3 18748 12670 2 56209 12670 2 4918 12670 1 26713 12670 2 ... |
| correct output |
|---|
| 0 0 0 0 0 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_r...
Test 31
Group: 6
Verdict: RUNTIME ERROR
| input |
|---|
| 67845 886519666 14071 38244 390226 23927 10508 4649507 24776 60617 7933069 44979 29276 6727041 ... |
| correct output |
|---|
| 43 0 395 0 81 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_r...
Test 32
Group: 6
Verdict: RUNTIME ERROR
| input |
|---|
| 70000 598182175 35387 18369 177725639 34272 27820 390474503 14996 60451 566274308 31897 35730 516503530 ... |
| correct output |
|---|
| 0 0 0 2373343036 2449703732 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_r...
Test 33
Group: 6
Verdict: RUNTIME ERROR
| input |
|---|
| 70000 307114024 18 68382 208881990 51105 51287 133487858 6935 48425 203987749 30063 35675 238707761 ... |
| correct output |
|---|
| 0 5457705 0 420055 0 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_r...
Test 34
Group: 6
Verdict: RUNTIME ERROR
| input |
|---|
| 70000 260495634 10465 32381 229572819 59714 8684 92922283 44269 63680 232833764 47600 15978 126514599 ... |
| correct output |
|---|
| 350035 839810 1 0 477281 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_r...
Test 35
Group: 6
Verdict: RUNTIME ERROR
| input |
|---|
| 70000 1000000000 40606 60962 166792 66689 16700 510579 39392 42623 271902 12827 150 783709 ... |
| correct output |
|---|
| 0 0 0 0 0 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_r...
Test 36
Group: 6
Verdict: RUNTIME ERROR
| input |
|---|
| 70000 1000000000 18028 63559 764765 43037 44898 469661 22315 22254 359926 32987 69384 314936 ... |
| correct output |
|---|
| 0 0 0 0 0 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_r...
Test 37
Group: 6
Verdict: RUNTIME ERROR
| input |
|---|
| 70000 1000000000 48195 15915 457746 7436 2784 442186 9122 3611 587852 31354 12943 476363 ... |
| correct output |
|---|
| 0 0 0 0 0 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_r...
Test 38
Group: 6
Verdict: RUNTIME ERROR
| input |
|---|
| 70000 852351984 54341 29527 743304598 55902 29527 379127182 8584 29527 326761145 21272 29527 850588761 ... |
| correct output |
|---|
| 0 0 0 0 0 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_r...
