結果
| 問題 | No.30 たこやき工場 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2018-07-01 03:31:54 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 214 ms / 5,000 ms | 
| コード長 | 896 bytes | 
| コンパイル時間 | 4,109 ms | 
| コンパイル使用メモリ | 77,496 KB | 
| 実行使用メモリ | 45,576 KB | 
| 最終ジャッジ日時 | 2024-12-21 05:27:58 | 
| 合計ジャッジ時間 | 6,832 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 17 | 
ソースコード
import java.util.*;
public class No030{
	static int[] dp;
	static int[][] in;
	
	static int dfs(int i, int n){
		if(i == n) return 1;
		if(dp[i] != 0) return dp[i];
		int res = 0;
		for(int j = 1; j < 101; j++){
			if(in[i][j] != 0){
				res += in[i][j]*dfs(j, n);
			}
		}
		return dp[i] = res;
	}
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		dp = new int[101];
		int[] ans = new int[101];
		Arrays.fill(ans, -1);
		in = new int[101][101];
		for(int i = 0; i < m; i++){
			int p = sc.nextInt();
			int q = sc.nextInt();
			int r = sc.nextInt();
			in[p][r] = q;
		}
		for(int i = 1; i < n; i++){
			boolean flg = true;
			for(int j = 1; j < 101; j++){
				if(in[j][i] != 0){
					System.out.println(0);
					flg = false;
					break;
				}
			}
			if(flg){
				System.out.println(dfs(i, n));
			}
		}
	}
}
            
            
            
        