結果

問題 No.1111 コード進行
ユーザー c-yanc-yan
提出日時 2020-07-10 23:04:18
言語 Go
(1.22.1)
結果
AC  
実行時間 784 ms / 2,000 ms
コード長 1,470 bytes
コンパイル時間 13,776 ms
コンパイル使用メモリ 229,168 KB
実行使用メモリ 9,740 KB
最終ジャッジ日時 2024-04-19 23:21:44
合計ジャッジ時間 18,118 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,812 KB
testcase_02 AC 1 ms
6,816 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 3 ms
6,940 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 10 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 1 ms
6,940 KB
testcase_18 AC 1 ms
6,944 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 1 ms
6,944 KB
testcase_21 AC 1 ms
6,940 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 1 ms
6,944 KB
testcase_25 AC 7 ms
6,940 KB
testcase_26 AC 22 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 1 ms
6,940 KB
testcase_29 AC 3 ms
6,940 KB
testcase_30 AC 185 ms
6,940 KB
testcase_31 AC 5 ms
6,944 KB
testcase_32 AC 303 ms
6,944 KB
testcase_33 AC 358 ms
7,008 KB
testcase_34 AC 2 ms
6,940 KB
testcase_35 AC 2 ms
6,944 KB
testcase_36 AC 2 ms
6,940 KB
testcase_37 AC 3 ms
6,940 KB
testcase_38 AC 208 ms
7,052 KB
testcase_39 AC 649 ms
8,192 KB
testcase_40 AC 784 ms
9,740 KB
testcase_41 AC 3 ms
6,940 KB
testcase_42 AC 4 ms
6,944 KB
testcase_43 AC 490 ms
8,212 KB
testcase_44 AC 2 ms
6,940 KB
testcase_45 AC 2 ms
6,944 KB
testcase_46 AC 7 ms
6,944 KB
testcase_47 AC 7 ms
6,940 KB
testcase_48 AC 35 ms
6,944 KB
testcase_49 AC 3 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	m = 1000000007
)

func main() {
	defer flush()

	N := readInt()
	M := readInt()
	K := readInt()

	pqc := make([][][2]int, 301)
	for i := 0; i < M; i++ {
		P := readInt()
		Q := readInt()
		C := readInt()
		pqc[P] = append(pqc[P], [2]int{Q, C})
	}

	t := make([]map[int]int, 301)
	for i := 1; i < 301; i++ {
		t[i] = map[int]int{0: 1}
	}
	for i := 0; i < N-1; i++ {
		nt := make([]map[int]int, 301)
		for j := 1; j < 301; j++ {
			for k := range t[j] {
				for _, qc := range pqc[j] {
					q := qc[0]
					c := qc[1]
					v := k + c
					if nt[q] == nil {
						nt[q] = map[int]int{}
					}
					if v <= K {
						nt[q][v] += t[j][k]
						nt[q][v] %= m
					}
				}
			}
		}
		t = nt
	}

	result := 0
	for i := 1; i < 301; i++ {
		result += t[i][K]
		result %= m
	}
	println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}
0