結果

問題 No.1111 コード進行
ユーザー sca1lsca1l
提出日時 2020-07-20 21:35:26
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,676 bytes
コンパイル時間 3,058 ms
コンパイル使用メモリ 77,192 KB
実行使用メモリ 829,024 KB
最終ジャッジ日時 2023-08-26 01:32:19
合計ジャッジ時間 16,045 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 AC 123 ms
53,772 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 145 ms
56,288 KB
testcase_07 AC 170 ms
56,096 KB
testcase_08 AC 173 ms
55,944 KB
testcase_09 AC 175 ms
56,148 KB
testcase_10 AC 129 ms
55,760 KB
testcase_11 AC 169 ms
56,136 KB
testcase_12 WA -
testcase_13 AC 130 ms
55,788 KB
testcase_14 WA -
testcase_15 AC 137 ms
55,552 KB
testcase_16 AC 169 ms
55,992 KB
testcase_17 AC 127 ms
55,696 KB
testcase_18 AC 126 ms
55,416 KB
testcase_19 AC 122 ms
55,884 KB
testcase_20 AC 127 ms
55,740 KB
testcase_21 AC 131 ms
55,716 KB
testcase_22 AC 126 ms
55,788 KB
testcase_23 AC 138 ms
55,784 KB
testcase_24 AC 128 ms
55,908 KB
testcase_25 WA -
testcase_26 MLE -
testcase_27 MLE -
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(cmp >= k){
            //System.out.println(cmp);
            if(cnt == n && 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