結果

問題 No.30 たこやき工場
コンテスト
ユーザー tottoripaper
提出日時 2015-03-24 18:14:04
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 715 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 334 ms
コンパイル使用メモリ 68,924 KB
実行使用メモリ 11,300 KB
最終ジャッジ日時 2026-03-18 08:50:05
合計ジャッジ時間 7,001 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

// Wrongri-La Shower

#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>

typedef long long ll;

struct Edge{
    int to;
    ll cost;
};

int N, M;
std::vector<Edge> G[101];
int count[101], degree[101];

void dfs(int u, int v, int c){
    if(u == N){count[v] += c; return;}
    
    for(const auto& e : G[u]){
        dfs(e.to, v, c * e.cost);
    }
}

int main(){
    scanf("%d %d", &N, &M);

    for(int i=0;i<M;i++){
        int p, q, r;
        scanf("%d %d %d", &p, &q, &r);
        
        G[p].push_back({r, q});
        ++degree[r];
    }

    for(int i=1;i<N;i++){
        if(degree[i] == 0){dfs(i, i, 1);}
    }

    for(int i=1;i<N;i++){
        printf("%d\n", count[i]);
    }
}
0