結果
| 問題 |
No.1170 Never Want to Walk
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-03-12 23:50:23 |
| 言語 | Go (1.23.4) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,300 bytes |
| コンパイル時間 | 13,458 ms |
| コンパイル使用メモリ | 253,028 KB |
| 実行使用メモリ | 20,704 KB |
| 最終ジャッジ日時 | 2025-03-12 23:50:47 |
| 合計ジャッジ時間 | 23,053 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 |
| other | WA * 37 |
ソースコード
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
var StationList = []int{}
var Answer = [][]int{}
var Max = 0
var Min = 0
func main() {
sc := bufio.NewScanner(os.Stdin)
sc.Scan()
header := strings.Split(sc.Text(), " ")
Min, _ = strconv.Atoi(header[1])
Max, _ = strconv.Atoi(header[2])
sc.Scan()
for _, s := range strings.Split(sc.Text(), " ") {
v, _ := strconv.Atoi(s)
StationList = append(StationList, v)
}
Answer = make([][]int, len(StationList))
for baseIndex := range StationList {
if len(Answer[baseIndex]) == 0 {
memo := make([]int, len(StationList))
Answer[baseIndex] = append(Answer[baseIndex], baseIndex)
rec(baseIndex, baseIndex, &memo)
for _, index := range Answer[baseIndex] {
copy(Answer[baseIndex], Answer[index])
}
}
}
for _, v := range Answer {
fmt.Println(v)
}
}
func rec(baseIndex, index int, memo *[]int) {
(*memo)[index] = 1
for i := range StationList {
if (*memo)[i] == 0 {
if judge(index, i) {
Answer[baseIndex] = append(Answer[baseIndex], i)
rec(baseIndex, i, memo)
}
}
}
}
func judge(i, j int) bool {
diff := StationList[j] - StationList[i]
if diff < 0 {
diff = StationList[i] - StationList[j]
}
if (Min <= diff) && (diff <= Max) {
return true
} else {
return false
}
}