結果
問題 |
No.1170 Never Want to Walk
|
ユーザー |
|
提出日時 | 2025-03-12 23:53:16 |
言語 | Go (1.23.4) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,304 bytes |
コンパイル時間 | 12,439 ms |
コンパイル使用メモリ | 252,428 KB |
実行使用メモリ | 18,608 KB |
最終ジャッジ日時 | 2025-03-12 23:53:41 |
合計ジャッジ時間 | 20,791 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 25 WA * 12 |
ソースコード
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(len(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 } }