結果
| 問題 |
No.1111 コード進行
|
| コンテスト | |
| ユーザー |
c-yan
|
| 提出日時 | 2020-07-10 22:46:08 |
| 言語 | Go (1.23.4) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,458 bytes |
| コンパイル時間 | 15,335 ms |
| コンパイル使用メモリ | 240,860 KB |
| 実行使用メモリ | 10,768 KB |
| 最終ジャッジ日時 | 2024-10-11 10:07:24 |
| 合計ジャッジ時間 | 19,352 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 40 WA * 8 |
ソースコード
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{}
}
if v <= 300 {
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...)
}
c-yan