結果

問題 No.351 市松スライドパズル
コンテスト
ユーザー tsuchinaga
提出日時 2019-04-16 16:59:17
言語 Go
(1.26.1)
コンパイル:
env GOCACHE=/tmp go build _filename_
実行:
./Main
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 736 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 13,523 ms
コンパイル使用メモリ 292,168 KB
実行使用メモリ 25,728 KB
最終ジャッジ日時 2026-04-10 14:15:57
合計ジャッジ時間 18,119 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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