結果

問題 No.30 たこやき工場
ユーザー kou6839kou6839
提出日時 2014-11-24 18:18:05
言語 Java19
(openjdk 21)
結果
AC  
実行時間 207 ms / 5,000 ms
コード長 1,110 bytes
コンパイル時間 2,117 ms
コンパイル使用メモリ 73,904 KB
実行使用メモリ 59,564 KB
最終ジャッジ日時 2023-08-23 05:14:20
合計ジャッジ時間 5,881 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
55,848 KB
testcase_01 AC 118 ms
53,716 KB
testcase_02 AC 121 ms
55,904 KB
testcase_03 AC 125 ms
56,132 KB
testcase_04 AC 125 ms
55,588 KB
testcase_05 AC 123 ms
55,596 KB
testcase_06 AC 130 ms
54,048 KB
testcase_07 AC 127 ms
55,708 KB
testcase_08 AC 177 ms
55,796 KB
testcase_09 AC 191 ms
55,852 KB
testcase_10 AC 207 ms
59,564 KB
testcase_11 AC 158 ms
55,972 KB
testcase_12 AC 128 ms
55,588 KB
testcase_13 AC 143 ms
55,676 KB
testcase_14 AC 185 ms
56,448 KB
testcase_15 AC 184 ms
56,280 KB
testcase_16 AC 193 ms
56,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.BigInteger;
import java.util.*;
 

public class Main {
	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];
        in = new int[101][101];
        for(int i=0;i<m;i++){
        	int a = sc.nextInt();
        	int b = sc.nextInt();
        	int c = sc.nextInt();
        	in[a][c]=b;
        }
        Arrays.fill(ans, -1);
        for(int i=1;i<n;i++){
        	boolean flag=true;
        	for(int j=1;j<101;j++){
        		if(in[j][i]!=0){
        			System.out.println(0);
        			flag=false;
        			break;
        		}
        	}
        	if(flag){
        		System.out.println(dfs(i,n));
        	}
        	
        }
        
        
    }
}
0