結果
| 問題 | No.30 たこやき工場 | 
| コンテスト | |
| ユーザー |  tottoripaper | 
| 提出日時 | 2015-03-24 18:14:04 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 715 bytes | 
| コンパイル時間 | 331 ms | 
| コンパイル使用メモリ | 44,900 KB | 
| 実行使用メモリ | 10,752 KB | 
| 最終ジャッジ日時 | 2024-06-29 00:33:22 | 
| 合計ジャッジ時間 | 6,976 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 10 TLE * 1 -- * 6 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:28:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   28 |     scanf("%d %d", &N, &M);
      |     ~~~~~^~~~~~~~~~~~~~~~~
main.cpp:32:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   32 |         scanf("%d %d %d", &p, &q, &r);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
            
            ソースコード
// 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]);
    }
}
            
            
            
        