結果

問題 No.30 たこやき工場
ユーザー face4face4
提出日時 2018-10-28 21:13:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 697 bytes
コンパイル時間 522 ms
コンパイル使用メモリ 71,392 KB
実行使用メモリ 13,880 KB
最終ジャッジ日時 2024-04-29 22:32:40
合計ジャッジ時間 7,118 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 4 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

struct Edge{
    int to, cost;
};

int n, m, p, q, r, indeg[100] = {};
vector<Edge> v[100];

ll dfs(int p, ll accum){
    if(p == n-1)    return accum;

    ll ret = 0;
    for(int i = 0; i < v[p].size(); i++){
        ret += dfs(v[p][i].to, accum*v[p][i].cost);
    }

    return ret;
}

int main(){
    cin >> n >> m;
    
    for(int i = 0; i < m; i++){
        cin >> p >> r >> q;
        p--, q--;
        indeg[q]++;
        v[p].push_back(Edge({q,r}));
    }

    for(int i = 0; i < n-1; i++){
        if(indeg[i])    cout << 0 << endl;
        else            cout << dfs(i, 1) << endl;
    }

    return 0;
}
0