結果

問題 No.351 市松スライドパズル
ユーザー yukirinyukirin
提出日時 2016-03-12 01:43:10
言語 Go
(1.22.1)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 789 bytes
コンパイル時間 14,817 ms
コンパイル使用メモリ 216,792 KB
実行使用メモリ 43,476 KB
最終ジャッジ日時 2023-10-25 07:24:50
合計ジャッジ時間 18,079 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
43,476 KB
testcase_01 AC 1 ms
4,372 KB
testcase_02 AC 1 ms
4,372 KB
testcase_03 AC 1 ms
4,372 KB
testcase_04 AC 2 ms
4,372 KB
testcase_05 AC 1 ms
4,372 KB
testcase_06 AC 1 ms
4,372 KB
testcase_07 AC 1 ms
4,372 KB
testcase_08 AC 1 ms
4,372 KB
testcase_09 AC 2 ms
4,372 KB
testcase_10 AC 1 ms
4,372 KB
testcase_11 AC 1 ms
4,372 KB
testcase_12 AC 1 ms
4,372 KB
testcase_13 AC 160 ms
41,400 KB
testcase_14 AC 161 ms
41,408 KB
testcase_15 AC 163 ms
43,472 KB
testcase_16 AC 164 ms
43,472 KB
testcase_17 AC 160 ms
43,476 KB
testcase_18 AC 162 ms
43,472 KB
testcase_19 AC 160 ms
43,472 KB
testcase_20 AC 155 ms
43,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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--
			if x < 0 {
				x = w - 1
			}
			continue
		}

		if x != ns[i][1] {
			continue
		}
		y--
		if y < 0 {
			y = h - 1
		}
	}

	s := true
	if y&1 == 0 {
		s = false
	}
	if x&1 == 0 {
		s = !s
	}

	if s == true {
		fmt.Println("white")
		return
	}
	fmt.Println("black")
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextLine())
	return i
}
0