結果

問題 No.1111 コード進行
ユーザー ngtkanangtkana
提出日時 2020-03-11 00:07:05
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 196 ms / 2,000 ms
コード長 1,387 bytes
コンパイル時間 973 ms
コンパイル使用メモリ 116,808 KB
実行使用メモリ 46,080 KB
最終ジャッジ日時 2024-04-27 19:00:51
合計ジャッジ時間 4,370 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
25,184 KB
testcase_01 AC 26 ms
25,420 KB
testcase_02 AC 25 ms
25,172 KB
testcase_03 AC 25 ms
27,212 KB
testcase_04 AC 25 ms
27,216 KB
testcase_05 AC 26 ms
25,440 KB
testcase_06 AC 28 ms
28,424 KB
testcase_07 AC 28 ms
26,336 KB
testcase_08 AC 27 ms
27,320 KB
testcase_09 AC 28 ms
25,564 KB
testcase_10 AC 29 ms
25,392 KB
testcase_11 AC 25 ms
25,140 KB
testcase_12 AC 29 ms
26,412 KB
testcase_13 AC 27 ms
25,784 KB
testcase_14 AC 31 ms
29,176 KB
testcase_15 AC 26 ms
25,276 KB
testcase_16 AC 29 ms
26,796 KB
testcase_17 AC 28 ms
29,416 KB
testcase_18 AC 26 ms
24,884 KB
testcase_19 AC 26 ms
27,188 KB
testcase_20 AC 25 ms
25,312 KB
testcase_21 AC 24 ms
25,040 KB
testcase_22 AC 27 ms
30,504 KB
testcase_23 AC 26 ms
27,700 KB
testcase_24 AC 26 ms
25,908 KB
testcase_25 AC 33 ms
28,076 KB
testcase_26 AC 27 ms
26,332 KB
testcase_27 AC 24 ms
24,892 KB
testcase_28 AC 56 ms
46,080 KB
testcase_29 AC 43 ms
45,404 KB
testcase_30 AC 71 ms
43,396 KB
testcase_31 AC 30 ms
30,044 KB
testcase_32 AC 92 ms
43,472 KB
testcase_33 AC 99 ms
45,292 KB
testcase_34 AC 43 ms
43,240 KB
testcase_35 AC 57 ms
45,848 KB
testcase_36 AC 142 ms
43,640 KB
testcase_37 AC 61 ms
37,196 KB
testcase_38 AC 53 ms
35,928 KB
testcase_39 AC 137 ms
45,492 KB
testcase_40 AC 115 ms
43,956 KB
testcase_41 AC 70 ms
45,864 KB
testcase_42 AC 67 ms
43,240 KB
testcase_43 AC 82 ms
45,180 KB
testcase_44 AC 39 ms
35,504 KB
testcase_45 AC 58 ms
41,636 KB
testcase_46 AC 26 ms
25,008 KB
testcase_47 AC 196 ms
31,580 KB
testcase_48 AC 26 ms
25,264 KB
testcase_49 AC 26 ms
25,048 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Linq;

static class NagataKanaIsAGenius {
    public static void Main() {
        int[]qmk=Console.ReadLine().Split().Select(int.Parse).ToArray();
        int q=qmk[0];
        int m=qmk[1];
        int k=qmk[2];
        int n=0;
        Tuple<int,int,int>[]prog=Enumerable.Range(0,m).Select(_=>{
            int[]uvw=Console.ReadLine().Split().Select(int.Parse).ToArray();
            int u=uvw[0]-1;
            int v=uvw[1]-1;
            int w=uvw[2];
            if(n<u)n=u;
            if(n<v)n=v;
            return new Tuple<int,int,int>(u,v,w);
        }).ToArray();
        n++;
        int[]dp=new int[(k+1)*n];
        for(int i=0;i<n;i++)dp[i]=1;
        for(int i=0;i<q-1;i++){
            int[]new_dp=new int[(k+1)*n];
            for(int j=k;j>=0;j--){
                foreach(Tuple<int,int,int>uvw in prog){
                    int u=uvw.Item1;
                    int v=uvw.Item2;
                    int w=uvw.Item3;
                    if(w<=j){
                        AddAssign(ref new_dp[j*n+u],dp[(j-w)*n+v]);
                    }
                }
            }
            dp=new_dp;
        }
        int ans=0;
        for(int i=0;i<n;i++){
            AddAssign(ref ans,dp[k*n+i]);
        }
        Console.WriteLine(ans);
    }
    static int Mod=1000000007;
    static void AddAssign(ref int x,int y){x+=y;if(Mod<=x)x-=Mod;}
}
0