結果
問題 |
No.351 市松スライドパズル
|
ユーザー |
|
提出日時 | 2016-03-12 01:49:50 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 177 ms / 2,000 ms |
コード長 | 692 bytes |
コンパイル時間 | 11,110 ms |
コンパイル使用メモリ | 219,940 KB |
実行使用メモリ | 42,864 KB |
最終ジャッジ日時 | 2024-10-10 23:43:58 |
合計ジャッジ時間 | 14,182 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 17 |
ソースコード
package main import ( "bufio" "fmt" "os" "strconv" ) var sc = bufio.NewScanner(os.Stdin) func main() { sc.Split(bufio.ScanWords) h, w, n := nextInt(), nextInt(), nextInt() ns := make([][]int, n) for i := range ns { ns[i] = []int{int(nextLine()[0]), nextInt()} } x, y := 0, 0 for i := n - 1; i >= 0; i-- { if ns[i][0] == 'R' { if y != ns[i][1] { continue } x = (x + w - 1) % w continue } if x != ns[i][1] { continue } y = (y + h - 1) % h } if (x+y)&1 == 1 { fmt.Println("black") return } fmt.Println("white") } func nextLine() string { sc.Scan() return sc.Text() } func nextInt() int { i, _ := strconv.Atoi(nextLine()) return i }