QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#308225 | #7812. 旅游巴士 | james1BadCreeper | 100 ✓ | 106ms | 13608kb | C++14 | 1.1kb | 2024-01-19 19:18:02 | 2024-01-19 19:18:02 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
const i64 INF = 0x3f3f3f3f3f3f3f3f;
int n, m, k;
i64 d[10005][105];
bool vis[10005][105];
vector<pair<int, int>> G[10005];
void dijkstra(int s) {
#define pli pair<i64, int>
priority_queue<pli, vector<pli>, greater<pli>> q;
memset(d, 0x3f, sizeof d);
d[s][0] = 0; q.emplace(0, s);
while (!q.empty()) {
int u = q.top().second, p = q.top().first, t; q.pop();
if (vis[u][p % k]) continue; vis[u][p % k] = 1;
for (auto [v, w] : G[u]) {
if (p >= w) t = p;
else t = ((w - p + k - 1) / k) * k + p;
if (d[v][(t + 1) % k] > t + 1)
q.emplace(d[v][(t + 1) % k] = t + 1, v);
}
}
}
int main(void) {
ios::sync_with_stdio(0);
cin >> n >> m >> k;
while (m--) {
int u, v, w; cin >> u >> v >> w;
G[u].emplace_back(v, w);
}
dijkstra(1);
if (d[n][0] == INF) cout << "-1\n";
else cout << d[n][0] << "\n";
return 0;
}
詳細信息
Test #1:
score: 5
Accepted
time: 2ms
memory: 12236kb
input:
9 14 95 7 9 0 6 9 0 4 2 0 3 4 0 5 7 0 7 9 0 8 7 0 5 3 0 8 7 0 1 6 0 5 3 0 2 8 0 3 1 0 6 5 0
output:
190
result:
ok single line: '190'
Test #2:
score: 5
Accepted
time: 0ms
memory: 12152kb
input:
10 14 51 6 5 0 8 10 0 9 8 0 3 10 0 6 4 0 3 4 0 4 10 0 8 3 0 9 8 0 1 2 0 7 9 0 5 4 0 3 6 0 2 7 0
output:
-1
result:
ok single line: '-1'
Test #3:
score: 5
Accepted
time: 2ms
memory: 12716kb
input:
10 14 55 5 5 82801 3 4 748185 6 10 98839 3 8 797926 5 3 57690 9 7 37956 4 6 926122 10 2 958237 8 1 40578 9 2 62884 2 8 145245 8 5 426166 1 9 880408 7 2 162816
output:
926145
result:
ok single line: '926145'
Test #4:
score: 5
Accepted
time: 2ms
memory: 12048kb
input:
9 15 97 1 1 990149 6 4 393083 4 7 171280 6 7 635660 8 6 123113 1 2 384925 6 7 507533 8 6 416969 3 4 975110 2 5 575466 2 4 72458 7 9 923003 5 3 590414 4 8 733761 7 5 440313
output:
923052
result:
ok single line: '923052'
Test #5:
score: 5
Accepted
time: 2ms
memory: 12176kb
input:
10 14 54 9 2 881274 7 8 356423 3 10 853386 2 10 677512 4 9 834731 8 6 91987 9 4 907844 1 5 652146 2 1 60718 6 5 555396 3 7 531810 6 6 401437 5 3 593446 6 4 295196
output:
853416
result:
ok single line: '853416'
Test #6:
score: 5
Accepted
time: 3ms
memory: 13460kb
input:
9266 19317 1 2000 3207 0 8069 4574 0 4857 8821 0 909 2661 0 7210 4774 0 826 7545 0 4283 4611 0 1229 8673 0 6341 9026 0 802 1762 0 300 473 0 4052 3766 0 7111 5319 0 1990 6824 0 852 475 0 6355 2588 0 5422 3626 0 4821 8355 0 4834 3221 0 4271 2262 0 7394 355 0 2847 6719 0 9089 2365 0 5663 422 0 1473 164...
output:
2594
result:
ok single line: '2594'
Test #7:
score: 5
Accepted
time: 6ms
memory: 13572kb
input:
9867 19871 1 9288 6774 0 541 9347 0 6950 4826 0 6587 180 0 7573 2835 0 3347 5023 0 9466 2489 0 6733 4683 0 6602 3743 0 4904 5408 0 5450 8761 0 3978 757 0 1145 693 0 1468 5549 0 9020 5597 0 4440 2108 0 7673 8305 0 9334 1140 0 3547 8505 0 8427 6898 0 9442 8015 0 9340 8140 0 1554 3692 0 9050 9376 0 781...
output:
2877
result:
ok single line: '2877'
Test #8:
score: 5
Accepted
time: 6ms
memory: 13320kb
input:
9342 19240 1 249 8909 363065 7613 6678 408923 6498 4312 540704 8171 6096 761352 6802 1281 739632 2957 2957 120021 3220 8158 562021 2148 7482 723634 1758 5739 525798 4926 1915 619426 6351 8751 712231 2663 856 188902 2198 3030 289802 9100 3893 970430 4207 6036 61420 47 824 62081 8715 8435 132002 1783 ...
output:
1001128
result:
ok single line: '1001128'
Test #9:
score: 5
Accepted
time: 3ms
memory: 13300kb
input:
9513 18340 1 4654 8721 10267 515 6153 327507 8226 4028 335114 4721 4217 756930 5060 1050 858391 5698 7278 571067 1986 6553 42520 6238 7193 190453 3114 1405 877455 9508 8508 279405 5233 6525 871266 7195 7195 71784 6229 3086 801474 115 9026 131532 5871 1341 826938 2327 2637 975366 4580 2807 303507 696...
output:
999770
result:
ok single line: '999770'
Test #10:
score: 5
Accepted
time: 3ms
memory: 13360kb
input:
9572 18518 1 4142 7857 878799 5686 677 765800 4940 3448 573893 1991 8493 302843 1793 2837 528763 3828 3770 888931 7475 2040 31638 4722 7971 126370 2030 1064 104636 9154 145 678140 3680 5416 196350 7231 7591 381499 7372 5404 953492 1366 4379 181509 7630 7911 480363 4289 9121 899481 1593 1325 336779 8...
output:
1000022
result:
ok single line: '1000022'
Test #11:
score: 5
Accepted
time: 50ms
memory: 13396kb
input:
9640 18640 55 1955 5950 0 3202 7642 0 9543 8057 0 2009 904 0 3859 9114 0 6215 4770 0 901 9112 0 40 8654 0 3708 4823 0 4710 1206 0 2682 7482 0 7252 1525 0 5742 2055 0 6433 1846 0 4655 7575 0 1869 3137 0 981 3256 0 6787 8775 0 9457 1928 0 6474 5027 0 1360 571 0 7907 2457 0 5727 880 0 3259 3716 0 8725 ...
output:
3025
result:
ok single line: '3025'
Test #12:
score: 5
Accepted
time: 76ms
memory: 13296kb
input:
9755 19120 88 4148 2875 0 5217 8212 0 2881 6290 0 8403 7450 0 6922 3068 0 1467 8661 0 8142 4011 0 2356 2117 0 1159 8427 0 6059 2953 0 4504 5230 0 1703 4652 0 7681 2262 0 4733 5664 0 3598 8005 0 388 388 0 9408 3377 0 5046 7386 0 2869 3002 0 8532 6788 0 6290 1193 0 4644 8820 0 3881 9139 0 3869 8824 0 ...
output:
2992
result:
ok single line: '2992'
Test #13:
score: 5
Accepted
time: 76ms
memory: 13548kb
input:
9840 18511 80 8357 7609 0 2141 6907 0 6725 6524 0 2513 4614 0 4090 1499 0 5135 9333 0 774 1936 0 578 578 0 8208 4206 0 3331 1916 0 5851 2702 0 2848 4654 0 6111 5807 0 163 9509 0 4682 9576 0 7242 612 0 2395 8303 0 7920 8018 0 7942 2593 0 8913 6226 0 8671 3339 0 6888 8133 0 5391 881 0 6802 3427 0 6244...
output:
3360
result:
ok single line: '3360'
Test #14:
score: 5
Accepted
time: 61ms
memory: 13416kb
input:
9504 18794 51 899 900 637797 5745 5751 70221 2068 2076 270062 343 344 142285 4313 4314 91858 2183 2184 69574 5732 5734 991959 1879 1886 382888 6423 6424 57934 4691 4692 886459 1374 1375 802248 6748 6749 473133 6505 6506 799627 8447 8448 157324 1661 1662 72178 4100 4110 233663 6621 6622 411454 4098 4...
output:
974202
result:
ok single line: '974202'
Test #15:
score: 5
Accepted
time: 94ms
memory: 13548kb
input:
9821 18934 78 746 747 944389 5436 5437 947846 667 675 550292 4773 4779 96464 600 601 66269 8006 8010 470573 9713 9720 708785 2879 2885 227304 5562 5563 217676 840 841 188647 3502 3509 281168 3232 3234 105962 6779 6780 701790 8318 8327 12272 6431 6439 552094 5467 5468 838401 251 254 88679 3486 3496 2...
output:
977418
result:
ok single line: '977418'
Test #16:
score: 5
Accepted
time: 106ms
memory: 13356kb
input:
9693 19498 97 500 8929 466939 4695 350 665912 2712 9144 132548 5668 7376 817512 2406 3652 786389 5057 5831 706611 692 2140 98634 3534 7603 10675 6251 5172 38255 8065 6935 238603 7948 92 550809 4899 6376 590515 6963 7095 182197 2775 4360 89655 4029 1959 380597 7563 7265 701907 5957 2574 728146 7210 8...
output:
999585
result:
ok single line: '999585'
Test #17:
score: 5
Accepted
time: 79ms
memory: 13608kb
input:
9646 18363 83 435 121 888409 1613 6126 682103 6754 1494 826961 2568 7398 272799 961 2869 658914 9276 7979 771435 949 6590 853475 9198 181 445785 5848 4847 393874 6724 1611 746891 7801 287 339837 400 2493 533151 9400 8136 465405 6802 464 450995 1806 4308 910622 2541 141 550812 3363 6559 675984 8991 8...
output:
1001478
result:
ok single line: '1001478'
Test #18:
score: 5
Accepted
time: 73ms
memory: 13372kb
input:
9313 18764 75 9266 2428 96888 1703 1499 51313 8426 9041 675850 7608 3527 752630 3283 466 412454 2093 5586 82055 3713 8741 632957 2580 8365 489655 2415 83 810805 6581 1608 304463 5207 1053 578271 5788 3384 195722 1592 927 182777 1648 1844 419354 46 7764 624893 4184 7389 264998 7131 3424 698477 3440 4...
output:
999375
result:
ok single line: '999375'
Test #19:
score: 5
Accepted
time: 76ms
memory: 13436kb
input:
9708 18428 71 7276 2226 213027 3520 1734 914615 7363 7837 753125 6798 5303 688090 9369 2710 315744 203 8935 324640 7938 9099 342555 3149 4617 886453 6430 8948 268190 8092 4771 633297 4645 5213 945040 4352 4352 517062 8746 6419 124499 2970 1884 555057 3858 4767 105670 7890 1267 477651 6086 6877 86834...
output:
1000177
result:
ok single line: '1000177'
Test #20:
score: 5
Accepted
time: 63ms
memory: 13372kb
input:
9490 19373 68 2413 8708 526411 9155 6622 92153 1990 2864 804840 6073 2924 595953 5487 8201 618375 4342 8047 42740 8420 3186 221604 6191 2577 555739 4022 4792 765954 8929 3200 403240 5390 7213 547290 2346 6643 425759 6069 3059 263528 3957 6471 785024 7409 4747 419974 6662 5627 327971 3941 4828 17760 ...
output:
1000416
result:
ok single line: '1000416'