QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#842594#9960. Baggageucup-team133#WA 0ms3812kbC++231.8kb2025-01-04 13:36:282025-01-04 13:36:30

Judging History

This is the latest submission verdict.

  • [2025-01-04 13:36:30]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3812kb
  • [2025-01-04 13:36:28]
  • Submitted

answer

#include <bits/stdc++.h>
#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void(0)
#endif

template <class T, class U = T> bool chmin(T& x, U&& y) {
    return y < x and (x = std::forward<U>(y), true);
}

template <class T, class U = T> bool chmax(T& x, U&& y) {
    return x < y and (x = std::forward<U>(y), true);
}

template <class T> void mkuni(std::vector<T>& v) {
    std::ranges::sort(v);
    auto result = std::ranges::unique(v);
    v.erase(result.begin(), result.end());
}

template <class T> int lwb(const std::vector<T>& v, const T& x) {
    return std::distance(v.begin(), std::ranges::lower_bound(v, x));
}

using namespace std;

using ll = long long;

const ll INF = 1e18;

void solve() {
    int n, m;
    cin >> n >> m;
    vector G(3, vector(n, vector<ll>(n, INF)));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < n; j++) {
            G[i][j][j] = 0;
        }
    }
    for (; m--;) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--, b--;
        for (int i = 0; i <= d; i++) {
            chmin(G[i][a][b], c);
        }
    }

    for (int d = 0; d < 3; d++) {
        for (int k = 0; k < n; k++) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    chmin(G[d][i][j], G[d][i][k] + G[d][k][j]);
                }
            }
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            ll ans = INF;
            for (int k = 0; k < n; k++) {
                chmin(ans, G[2][i][k] + G[1][k][j] + G[0][j][k] + G[1][k][j]);
            }
            cout << (ans == INF ? -1 : ans) << " \n"[j + 1 == n];
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    solve();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3812kb

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: 0ms
memory: 3636kb

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 28...

result:

wrong answer 4th numbers differ - expected: '2449', found: '2954'