結果
問題 | No.1111 コード進行 |
ユーザー |
![]() |
提出日時 | 2020-07-20 21:35:26 |
言語 | Java (openjdk 23) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,676 bytes |
コンパイル時間 | 2,523 ms |
コンパイル使用メモリ | 79,472 KB |
実行使用メモリ | 833,932 KB |
最終ジャッジ日時 | 2024-12-24 14:17:45 |
合計ジャッジ時間 | 32,107 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 MLE * 1 |
other | AC * 25 WA * 9 MLE * 14 |
ソースコード
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); } }