QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#841874 | #9960. Baggage | ucup-team3555# | WA | 2ms | 7804kb | C++20 | 1.1kb | 2025-01-04 08:32:09 | 2025-01-04 08:32:09 |
Judging History
answer
/*
*/
# include <bits/stdc++.h>
const int N=405,INF=0x3f3f3f3f;
inline int read(void){
int res,f=1;
char c;
while((c=getchar())<'0'||c>'9')
if(c=='-') f=-1;
res=c-48;
while((c=getchar())>='0'&&c<='9')
res=res*10+c-48;
return res*f;
}
typedef long long ll;
ll dis[3][N][N]; // 012 dis
int n,m;
inline void floyd(ll d[N][N]){
for(int k=1;k<=n;++k){
for(int i=1;i<=n;++i){
for(int j=1;j<=n;++j){
d[i][j]=std::min(d[i][j],d[i][k]+d[k][j]);
}
}
}
return;
}
int main(void){
n=read(),m=read(); memset(dis,INF,sizeof(dis));
for(int i=1;i<=n;++i) dis[0][i][i]=dis[1][i][i]=dis[2][i][i]=0;
for(int i=1;i<=m;++i){
int u=read(),v=read(),w=read(),l=read();
for(int x=0;x<=l;++x) dis[x][u][v]=std::min(dis[x][u][v],1ll*w);
}
floyd(dis[0]),floyd(dis[1]);
for(int i=1;i<=n;++i){
for(int j=1;j<=n;++j){
dis[2][i][j]=std::min(dis[2][i][j],2ll*dis[1][i][j]+dis[0][j][i]);
}
}
floyd(dis[2]);
for(int i=1;i<=n;++i){
for(int j=1;j<=n;++j){
printf("%lld ",dis[2][i][j]<=1e18?dis[2][i][j]:-1);
}
puts("");
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 7672kb
input:
5 7 1 2 500 2 2 3 100 1 3 5 20 2 5 4 5 1 4 2 1 0 3 4 40 2 5 4 77 1
output:
0 500 726 751 746 -1 0 226 251 246 -1 -1 0 40 20 -1 -1 -1 0 -1 -1 -1 -1 131 0
result:
ok 25 numbers
Test #2:
score: 0
Accepted
time: 2ms
memory: 7668kb
input:
30 5000 1 15 15034 0 1 15 15034 0 24 28 14745 2 1 15 15034 0 16 25 13210 0 16 22 26942 0 24 20 5423 1 4 12 636 0 16 12 19327 0 1 15 15034 0 1 15 15034 0 3 28 18940 2 1 15 15034 0 15 9 6468 0 20 3 6233 2 19 4 10829 2 1 15 15034 0 26 6 20998 0 1 15 15034 0 1 15 15034 0 1 15 15034 0 4 14 20515 2 1 15 1...
output:
0 868 1159 2449 3001 1108 1557 3972 596 1521 3923 1332 3230 871 2010 2145 1610 783 2009 1490 2120 3440 2627 4515 228 958 2630 4394 3681 2618 2534 0 291 3106 3753 3127 4053 4838 3130 2387 4580 464 4486 1719 2784 2818 2476 3317 2343 777 2777 3121 1759 5381 2762 1354 5164 6928 3603 3370 2243 3111 0 2...
result:
ok 900 numbers
Test #3:
score: 0
Accepted
time: 0ms
memory: 7652kb
input:
30 5000 30 9 1929 2 14 1 270 1 3 4 709 0 13 8 14 0 23 16 423 0 18 12 14 0 11 28 658 0 19 3 6793 1 16 25 9438 0 1 15 25 0 5 26 3 1 14 18 11 2 13 19 131 1 14 1 441 0 7 14 16 1 6 3 4624 1 29 5 639 1 2 16 66 1 3 27 770 2 4 21 9 1 11 22 22681 0 15 20 3380 0 21 14 1 0 18 26 3 0 14 16 60 1 30 18 8284 1 12 ...
output:
0 3 8 4 4 6 3 5 5 7 3 15 4 5 9 11 5 4 9 3 8 6 5 6 4 4 5 9 2 4 6 0 8 4 8 9 7 3 6 8 7 12 8 8 13 12 8 8 13 7 11 9 9 7 8 8 5 10 6 8 7 9 0 8 1 4 7 6 6 6 5 13 11 3 6 9 4 3 10 4 7 4 4 7 5 5 9 7 9 6 7 7 7 0 4 6 3 5 4 7 3 15 4 5 9 8 5 5 9 4 7 6 5 3 4 5 1 6 2 4 10 8 5 9 0 3 11 11 11 11 10 18 12 8 11 9 9 8...
result:
ok 900 numbers
Test #4:
score: 0
Accepted
time: 2ms
memory: 7796kb
input:
30 5000 25 18 30000 0 10 17 29987 1 10 17 29987 1 10 17 29987 1 10 17 29987 1 10 17 29987 0 27 23 26494 1 10 17 29987 0 10 17 29987 0 25 18 30000 0 25 18 30000 0 10 17 29987 0 25 18 30000 0 10 17 29987 0 5 19 29447 1 10 17 29987 1 10 17 29987 0 10 17 29987 1 10 17 29987 0 10 17 29987 0 5 27 29658 0 ...
output:
0 36060 30000 33186 30484 21948 47316 32912 49004 33187 51932 39740 29995 33186 22914 51948 47860 32846 28861 41502 29921 29752 51698 29544 20571 3187 29894 49129 28597 50559 46239 0 29986 29999 27920 35457 19997 29997 52925 46696 46671 36825 33191 43503 49029 16716 51056 46355 18871 29833 46145 26...
result:
ok 900 numbers
Test #5:
score: 0
Accepted
time: 2ms
memory: 7656kb
input:
30 2610 3 20 5637 2 18 29 12579 1 21 8 2321 1 29 19 5569 1 18 9 4241 0 8 30 4854 2 26 25 2044 0 24 16 2735 1 15 22 10162 2 3 22 8632 1 15 2 5624 2 13 11 10791 2 6 12 956 2 19 4 1604 1 6 23 4864 0 5 11 3258 1 13 5 209 1 1 25 15792 1 7 17 2018 1 5 12 3274 0 30 12 12854 1 1 13 11766 2 13 20 4031 1 13 1...
output:
0 596 683 173 89 374 215 336 68 321 103 247 135 170 440 1226 921 324 406 886 69 259 526 90 395 614 712 235 451 636 781 0 763 448 330 711 456 110 413 597 448 592 159 411 616 1546 901 771 308 1161 414 283 767 331 636 739 953 450 622 877 121 717 0 294 210 495 336 451 189 442 224 368 256 291 561 1347 ...
result:
ok 900 numbers
Test #6:
score: 0
Accepted
time: 2ms
memory: 7616kb
input:
30 5000 23 1 120577749 0 23 1 932974878 2 23 1 496789200 0 23 1 387748955 0 23 1 65652724 2 23 1 357942661 2 27 26 26637 1 23 1 322699534 1 23 1 380812839 2 23 1 953517727 2 23 1 749461966 1 10 15 28782 2 23 1 928219419 2 23 1 710721749 2 8 15 18680 1 23 1 892884272 1 23 1 286930033 1 23 1 218608754...
output:
0 27320 24887 26618 42869 21776 48355 33767 24719 42203 43789 28450 29649 45609 36687 27601 41308 29758 43974 49891 37258 23888 26839 36717 29133 43599 43773 25044 34014 19905 44931 0 44262 27639 40476 24628 28243 27005 23206 24976 25906 29578 20816 20297 28743 25208 29929 36582 29084 30428 39611 2...
result:
ok 900 numbers
Test #7:
score: 0
Accepted
time: 0ms
memory: 7612kb
input:
30 5000 29 20 714766588 0 2 7 117691629 2 30 7 986874209 0 24 20 59391779 0 14 11 910689121 1 27 21 674552800 0 13 2 19137 1 29 27 575469961 0 20 16 997757597 1 10 14 894507242 0 22 25 371074859 1 27 4 148067345 1 16 1 75228920 2 17 4 62090300 1 2 24 4378 0 24 27 513864617 1 10 3 51701509 1 10 12 86...
output:
0 26 37 43 54 77 989 26 1179 46 79 2308 39 736 1328 1176 58 726 54 695 5052 26 1185 21 207 5 430 52 5552 51 716 0 753 759 770 793 1705 742 1895 762 795 3024 755 1452 2044 1892 774 1442 770 1411 5768 742 1901 737 923 721 1146 768 6268 767 755 39 0 6 36 42 952 6 1159 28 61 3063 2 984 1304 1156 40 97...
result:
ok 900 numbers
Test #8:
score: 0
Accepted
time: 0ms
memory: 7612kb
input:
30 5000 18 19 411628368 0 18 19 992076423 0 18 19 982786362 1 18 19 869144808 0 18 19 604720156 1 18 19 150564302 1 18 19 976935570 0 18 19 969698875 1 18 19 704977028 0 18 19 763570567 0 18 19 595200455 1 18 19 90807561 1 18 19 108104079 0 18 19 480474814 0 18 19 309125116 1 18 19 363086156 0 18 19...
output:
0 20024 51335 65397 86394 93878 158429 187393 224779 249597 272512 298527 363157 369316 421368 437257 473456 489365 553804 566015 629870 655713 672117 688654 750372 764687 803012 815477 879905 897017 926822 0 31311 45373 66370 73854 138405 167369 204755 229573 252488 278503 343133 349292 401344 417...
result:
ok 900 numbers
Test #9:
score: 0
Accepted
time: 2ms
memory: 7804kb
input:
30 59 11 25 4982 0 1 16 26498 1 26 27 4960 1 27 28 29446 1 19 4 14770 0 12 26 5084 0 8 22 23140 0 9 23 16857 0 1 2 11246 1 30 15 1948 0 23 8 29970 0 27 12 13101 0 4 5 17481 1 15 29 29113 0 25 26 11246 1 6 7 4354 1 29 14 25845 0 28 13 21802 0 25 10 6407 0 3 4 29446 1 16 17 26602 1 8 9 18521 1 13 27 1...
output:
0 62004 168048 257690 310001 384929 417726 496176 580045 640010 681867 768366 819883 912971 977849 68399 171414 252577 298028 364021 421921 497038 585110 648001 700797 756690 784795 880035 957324 1003327 -1 0 106044 195686 247997 322925 355722 434172 518041 578006 619863 706362 757879 850967 915845...
result:
ok 900 numbers
Test #10:
score: -100
Wrong Answer
time: 2ms
memory: 7688kb
input:
30 5000 12 13 22419 1 12 13 22419 1 12 13 22419 0 12 13 22419 1 12 13 22419 1 12 13 22419 0 12 13 22419 1 12 13 22419 0 12 13 22419 0 12 13 22419 0 12 13 22419 1 12 13 22419 0 12 13 22419 0 12 13 22419 1 12 13 22419 0 12 13 22419 0 12 13 22419 0 12 13 22419 0 12 13 22419 1 12 13 22419 0 12 13 22419 ...
output:
0 29478 4846 33196 -4774451407313060419 -4774451407313060419 -4774451407313060419 -4774451407313060419 -4774451407313060419 -4774451407313060419 -4774451407313060419 -4774451407313060419 -4774451407313060419 -4774451407313060419 -4774451407313060419 -4774451407313060419 -4774451407313060419 -4774451...
result:
wrong answer 5th numbers differ - expected: '-1', found: '-4774451407313060419'