QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#860032 | #9960. Baggage | lzm0107 | WA | 1ms | 7704kb | C++14 | 1.2kb | 2025-01-18 09:37:30 | 2025-01-18 09:37:30 |
Judging History
answer
#include <bits/stdc++.h>
#define lzm0107
using namespace std;
using LL = long long;
using AI2 = array<int, 2>;
using PII = pair<int, int>;
using ULL = unsigned long long;
const int N = 4e2 + 10;
int n, m;
LL f[3][N][N];
int main(){
ios::sync_with_stdio(false);
*cin.tie(nullptr) << fixed << setprecision(20);
memset(f, 0x3f, sizeof(f));
cin >> n >> m;
for(int i = 1; i <= n; i ++ ){
f[0][i][i] = f[1][i][i] = f[2][i][i] = 0;
}
for(int a, b, c, d, i = 1; i <= m; i ++ ){
cin >> a >> b >> c >> d;
for(int j = d; j >= 0; j -- ) f[j][a][b] = min(f[j][a][b], (long long)c);
}
for(int i = 0; i < 3; i ++ ){
for(int a = 1; a <= n; a ++ ){
for(int b = 1; b <= n; b ++ ){
for(int c = 1; c <= n; c ++ ){
f[i][b][c] = min(f[i][b][c], f[i][b][a] + f[i][a][c]);
}
}
}
}
for(int i = 1; i <= n; i ++ ){
for(int j = 1; j <= n; j ++ ){
LL res = 0x3f3f3f3f3f3f3f3f;
for(int k = 1; k <= n; k ++ ){
if(f[2][i][k] != 0x3f3f3f3f3f3f3f3f && f[1][k][j] != 0x3f3f3f3f3f3f3f3f && f[0][j][k] != 0x3f3f3f3f3f3f3f3f){
res = min(res, f[2][i][k] + (f[1][k][j] << 1) + f[0][j][k]);
}
}
cout << (res == 0x3f3f3f3f3f3f3f3f ? -1 : res) << ' ';
}
cout << '\n';
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 7704kb
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: -100
Wrong Answer
time: 1ms
memory: 7552kb
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 2954 3001 1108 1557 3972 596 1521 5089 1332 3230 871 2010 2145 1610 783 2677 1490 2120 3440 2627 4515 228 1088 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 ...
result:
wrong answer 4th numbers differ - expected: '2449', found: '2954'