結果

問題 No.468 役に立つ競技プログラミング実践編
ユーザー tubo28tubo28
提出日時 2016-12-12 13:19:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 313 ms / 2,000 ms
コード長 1,140 bytes
コンパイル時間 1,881 ms
コンパイル使用メモリ 172,752 KB
実行使用メモリ 18,336 KB
最終ジャッジ日時 2023-08-20 02:21:47
合計ジャッジ時間 7,144 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 2 ms
4,460 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 4 ms
4,388 KB
testcase_15 AC 5 ms
4,604 KB
testcase_16 AC 4 ms
4,420 KB
testcase_17 AC 4 ms
4,624 KB
testcase_18 AC 4 ms
4,436 KB
testcase_19 AC 4 ms
4,560 KB
testcase_20 AC 4 ms
4,380 KB
testcase_21 AC 4 ms
4,388 KB
testcase_22 AC 4 ms
4,432 KB
testcase_23 AC 4 ms
4,644 KB
testcase_24 AC 301 ms
18,080 KB
testcase_25 AC 301 ms
18,052 KB
testcase_26 AC 298 ms
18,096 KB
testcase_27 AC 306 ms
18,336 KB
testcase_28 AC 299 ms
18,180 KB
testcase_29 AC 305 ms
17,944 KB
testcase_30 AC 303 ms
18,012 KB
testcase_31 AC 299 ms
18,016 KB
testcase_32 AC 303 ms
18,180 KB
testcase_33 AC 313 ms
18,108 KB
testcase_34 AC 97 ms
17,884 KB
testcase_35 AC 3 ms
4,416 KB
testcase_36 AC 2 ms
4,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(dst, N) for (int dst = 0; dst < (int)(N); ++dst)
#define all(C) begin(C), end(C)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl

int N, M;
vector<vector<pair<int, int>>> g, rg;

int dpb[100010], dpr[100010];

int blue(int u) {
    int &res = dpb[u];
    if (res != -1) return res;
    res = 0;
    for (auto &e : rg[u]) res = max(res, blue(e.first) + e.second);
    return res;
}

int red(int u) {
    int &res = dpr[u];
    if (res != -1) return res;
    res = 1e9;
    for (auto &e : g[u]) res = min(res, red(e.first) - e.second);
    return res;
}

int main() {
    cin >> N >> M;
    g.assign(N, {});
    rg.assign(N, {});
    memset(dpb, -1, sizeof dpb);
    memset(dpr, -1, sizeof dpr);
    for (int i = 0; i < M; i++) {
        int A, B, C;
        cin >> A >> B >> C;
        g[A].emplace_back(B, C);
        rg[B].emplace_back(A, C);
    }
    blue(N - 1);
    dpr[N - 1] = dpb[N - 1];
    red(0);
    int p = 0;
    for (int i = 0; i < N; i++) {
        if (dpb[i] != dpr[i]) ++p;
    }
    printf("%d %d/%d\n", blue(N - 1), p, N);
}
0