結果

問題 No.1111 コード進行
ユーザー c-yanc-yan
提出日時 2020-07-10 22:34:00
言語 Go
(1.22.1)
結果
TLE  
実行時間 -
コード長 1,431 bytes
コンパイル時間 12,170 ms
コンパイル使用メモリ 224,112 KB
実行使用メモリ 28,056 KB
最終ジャッジ日時 2024-04-19 21:00:00
合計ジャッジ時間 18,928 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,624 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 33 ms
6,528 KB
testcase_07 AC 239 ms
9,984 KB
testcase_08 AC 294 ms
14,976 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 169 ms
10,584 KB
testcase_11 AC 102 ms
9,728 KB
testcase_12 AC 84 ms
7,168 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 296 ms
9,600 KB
testcase_15 AC 78 ms
11,392 KB
testcase_16 AC 93 ms
11,008 KB
testcase_17 AC 41 ms
6,272 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 96 ms
7,040 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 46 ms
8,832 KB
testcase_24 AC 24 ms
5,376 KB
testcase_25 AC 858 ms
26,368 KB
testcase_26 AC 64 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 149 ms
6,760 KB
testcase_29 AC 3 ms
5,376 KB
testcase_30 TLE -
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 #

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) % m
					if nt[q] == nil {
						nt[q] = map[int]int{}
					}
					nt[q][v] += t[j][k]
				}
			}
		}
		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