結果
| 問題 |
No.228 ゆきこちゃんの 15 パズル
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-02-27 21:13:15 |
| 言語 | Go (1.23.4) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,082 bytes |
| コンパイル時間 | 12,120 ms |
| コンパイル使用メモリ | 236,300 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-10 23:03:29 |
| 合計ジャッジ時間 | 11,738 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 15 WA * 2 |
ソースコード
package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
var sc = bufio.NewScanner(os.Stdin)
func main() {
sc.Split(bufio.ScanWords)
p := make([][]int, 6)
p[0] = []int{-1, -1, -1, -1, -1, -1}
p[5] = []int{-1, -1, -1, -1, -1, -1}
for i := 1; i < 5; i++ {
p[i] = []int{-1, nextInt(), nextInt(), nextInt(), nextInt(), -1}
}
ns := [][2]int{{1, 0}, {0, 1}, {-1, 0}, {0, -1}, {0, 0}}
for i := 1; i < 5; i++ {
for j := 1; j < 5; j++ {
n := (i-1)*4 + j
if n == 16 {
continue
}
adj := false
for _, pos := range ns {
nI, nJ := i+pos[1], j+pos[0]
if p[nI][nJ] == n {
adj = true
break
}
}
if !adj {
fmt.Println("No")
return
}
for _, pos := range ns[:2] {
if p[i+pos[1]][j+pos[0]] == -1 {
continue
}
next := (n + (pos[1] * 4) + pos[0]) % 16
if p[i][j] == next && p[i+pos[1]][j+pos[0]] == n {
fmt.Println("No")
return
}
}
}
}
fmt.Println("Yes")
}
func nextLine() string {
sc.Scan()
return sc.Text()
}
func nextInt() int {
i, _ := strconv.Atoi(nextLine())
return i
}