QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#842589 | #9960. Baggage | ucup-team6225# | WA | 1ms | 5884kb | C++17 | 2.0kb | 2025-01-04 13:35:22 | 2025-01-04 13:35:23 |
Judging History
answer
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
using ll = long long;
const ll N = 410, inf = 1e16, SZ = (1 << 18) + 5;
static char buf[SZ], *bgn = buf, *til = buf;
char getc() {
if(bgn == til) bgn = buf, til = buf + fread(buf, 1, SZ, stdin);
return bgn == til ? EOF : *bgn++;
}
template<typename T>
void read(T &x) {
char ch = getc(); T fh = 0; x = 0;
while(ch < '0' || ch > '9') fh |= (ch == '-'), ch = getc();
while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getc();
x = fh ? -x : x;
}
template<typename Type, typename... argc>
void read(Type &x, argc &...args) {read(x), read(args...);}
template<typename T>
void print(T x) {
if(x < 0) putchar('-'), x = -x;
if(x / 10) print(x / 10);
putchar(x % 10 + '0');
}
int n, m, g[N][N][3], u, v, op, w;
ll dis[N][N][3];
int main() {
#ifdef Kelly
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
freopen("err.txt", "w", stderr);
#endif
read(n, m);
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= n; ++j)
for(int k : {0, 1, 2}) dis[i][j][k] = inf + inf;
for(int i = 1; i <= m; ++i) {
read(u, v, w, op);
for(int j = 0; j <= op; ++j) dis[u][v][j] = min(dis[u][v][j], (ll)w);
}
for(int i = 1; i <= n; ++i) dis[i][i][0] = dis[i][i][1] = dis[i][i][2] = 0;
for(int u = 0; u <= 2; ++u)
for(int k = 1; k <= n; ++k)
for(int i = 1; i <= n; ++i) if(i != k)
for(int j = 1; j <= n; ++j) if(k != j && i != j) {
dis[i][j][u] = min(dis[i][j][u], dis[i][k][u] + dis[k][j][u]);
if(u == 2)
dis[i][j][2] = min(dis[i][j][2], dis[i][j][1] + dis[j][i][0] + dis[i][j][1]);
}
for(int i = 1; i <= n; ++i, cout << "\n")
for(int j = 1; j <= n; ++j) cout << (dis[i][j][2] < inf ? dis[i][j][2] : -1) << " ";
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 5720kb
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: 5884kb
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:
wrong answer 97th numbers differ - expected: '6431', found: '6770'