結果

問題 No.468 役に立つ競技プログラミング実践編
ユーザー nukachanukacha
提出日時 2017-05-05 03:42:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,677 bytes
コンパイル時間 659 ms
コンパイル使用メモリ 75,384 KB
実行使用メモリ 814,648 KB
最終ジャッジ日時 2023-10-12 08:26:19
合計ジャッジ時間 4,550 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,352 KB
testcase_10 AC 2 ms
4,352 KB
testcase_11 AC 2 ms
4,352 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 1 ms
4,352 KB
testcase_14 AC 10 ms
7,384 KB
testcase_15 AC 10 ms
7,584 KB
testcase_16 AC 9 ms
7,400 KB
testcase_17 AC 9 ms
7,320 KB
testcase_18 AC 9 ms
7,320 KB
testcase_19 AC 9 ms
7,324 KB
testcase_20 AC 9 ms
7,408 KB
testcase_21 AC 10 ms
7,380 KB
testcase_22 AC 9 ms
7,388 KB
testcase_23 AC 9 ms
7,592 KB
testcase_24 MLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <limits>

    int n, m;
    std::vector<std::vector<int> > edge;    // 隣接行列
    std::vector<int> ent, lnt;
    std::vector<int> rec, ser;

void calc_ent(int node) {
    if (rec[node] != 0) {
        return;
    }
    for (int i = 0; i < n; i++) {
        if (edge[node][i] != -1) {
            int t = ent[node] + edge[node][i];
            if (t > ent[i]) {
                ent[i] = t;
            }
            rec[i]--;
            calc_ent(i);
        }
    }
    rec[node]--;
    return;
}

void calc_lnt(int node) {
    if (ser[node] != 0) {
        return;
    }
    for (int i = 0; i < n; i++) {
        if (edge[i][node] != -1) {
            int t = lnt[node] - edge[i][node];
            if (t < lnt[i]) {
                lnt[i] = t;
            }
            ser[i]--;
            calc_lnt(i);
        }
    }
    ser[node]--;
    return;
}

int main() {
    int tmp[3] = {0};
    int c = 0;
    std::cin >> n >> m;
    edge.resize(n);
    for (int i = 0; i < n; i++) {
        edge[i].resize(n, -1);
    }
    ent.resize(n, 0);
    ent[0] = 0;
    lnt.resize(n, std::numeric_limits<int>::max());
    rec.resize(n, 0);
    ser.resize(n, 0);
    for (int i = 0; i < m; i++) {
        std::cin >> tmp[0] >> tmp[1] >> tmp[2];
        if (tmp[2] > edge[tmp[0]][tmp[1]]) {
            edge[tmp[0]][tmp[1]] = tmp[2];
            ser[tmp[0]]++;
            rec[tmp[1]]++;
        }
    }
    calc_ent(0);
    lnt[n-1] = ent[n-1];
    calc_lnt(n-1);
    for (int i = 0; i < n; i++) {
        if (lnt[i] != ent[i]) {
            c++;
        }
    }
    std::cout << ent[n-1] << " " << c << "/" << n << std::endl;
    
}
0