結果

問題 No.351 市松スライドパズル
ユーザー tsuchinaga
提出日時 2019-04-16 16:59:17
言語 Go
(1.23.4)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 736 bytes
コンパイル時間 11,291 ms
コンパイル使用メモリ 224,376 KB
実行使用メモリ 26,216 KB
最終ジャッジ日時 2024-09-22 08:19:40
合計ジャッジ時間 14,823 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var h, w, n int
	_, _ = fmt.Scan(&h, &w, &n)

	type c struct {
		s string
		k int
	}

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	controls := make([]c, n)
	for i := range controls {
		sc.Scan()
		controls[i].s = sc.Text()

		sc.Scan()
		controls[i].k, _ = strconv.Atoi(sc.Text())
	}

	var x, y int
	for i := n - 1; i >= 0; i-- {
		if controls[i].s == "R" && controls[i].k == y {
			x = (x + w - 1) % w
		} else if controls[i].s == "C" && controls[i].k == x {
			y = (y + h - 1) % h
		}
		// fmt.Println(controls[i], x, y)
	}
	// fmt.Println(x, y)

	ans := (x + y) % 2
	if ans == 1 {
		fmt.Println("black")
	} else {
		fmt.Println("white")
	}
}
0