結果

問題 No.1111 コード進行
ユーザー sca1lsca1l
提出日時 2020-07-20 21:26:09
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,625 bytes
コンパイル時間 2,289 ms
コンパイル使用メモリ 77,016 KB
実行使用メモリ 61,124 KB
最終ジャッジ日時 2023-08-26 01:21:34
合計ジャッジ時間 8,698 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
60,404 KB
testcase_01 AC 101 ms
55,572 KB
testcase_02 AC 108 ms
55,752 KB
testcase_03 AC 106 ms
56,252 KB
testcase_04 AC 100 ms
56,084 KB
testcase_05 AC 102 ms
54,276 KB
testcase_06 AC 156 ms
55,948 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main{
    
    static final int MOD = (int)1e9+7;
    static final int MAX = 301;
    static int n;
    static int m;
    static int k;
    static ArrayList<Integer>[] graph;
    static ArrayList<Integer>[] complexity;
    
    public static int dfs(int now, int cmp, int cnt){
        if(cnt == n){
            if(cmp == k){
                return 1;
            }else{
                return 0;
            }
        }
        
        int ret = 0;
        for(int i=0; i<graph[now].size(); i++){
            int next = graph[now].get(i);
            int cmpsum = complexity[now].get(i) + cmp;
            ret += dfs(next, cmpsum, cnt+1);
            ret %= MOD;
        }
        return ret%MOD;
    }
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        n = Integer.parseInt(sc.next());
        m = Integer.parseInt(sc.next());
        k = Integer.parseInt(sc.next());
        
        graph = new ArrayList[MAX];
        complexity = new ArrayList[MAX];
        for(int i=0; i<MAX; i++){
            graph[i] = new ArrayList<>();
            complexity[i] = new ArrayList<>();
        }
        for(int i=0; i<m; i++){
            int p = Integer.parseInt(sc.next())-1;
            int q = Integer.parseInt(sc.next())-1;
            int c = Integer.parseInt(sc.next());
            
            graph[p].add(q);
            complexity[p].add(c);
        }
        
        int ans = 0;
        for(int i=0; i<MAX; i++){
            ans += dfs(i, 0, 1);
            ans %= MOD;
        }
        
        System.out.println(ans);
    }
}
0