結果

問題 No.351 市松スライドパズル
ユーザー ccppjsrbccppjsrb
提出日時 2020-05-28 17:54:22
言語 Go
(1.22.1)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 1,918 bytes
コンパイル時間 11,979 ms
コンパイル使用メモリ 225,940 KB
実行使用メモリ 26,240 KB
最終ジャッジ日時 2024-04-21 05:56:59
合計ジャッジ時間 15,566 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
26,240 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 127 ms
25,600 KB
testcase_14 AC 131 ms
25,856 KB
testcase_15 AC 140 ms
26,240 KB
testcase_16 AC 137 ms
26,240 KB
testcase_17 AC 125 ms
26,240 KB
testcase_18 AC 127 ms
26,240 KB
testcase_19 AC 138 ms
26,240 KB
testcase_20 AC 138 ms
26,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 3
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	h := getNextInt(scanner)
	w := getNextInt(scanner)
	n := getNextInt(scanner)
	qq := make([]query, n)
	for i := n - 1; i >= 0; i-- {
		qq[i].s = getNextString(scanner)
		qq[i].k = getNextInt(scanner)
	}
	y := 0
	x := 0
	for i := 0; i < n; i++ {
		if qq[i].s == "R" {
			if y == qq[i].k {
				x = mod(x-1, w)
			}
			continue
		}
		if x == qq[i].k {
			y = mod(y-1, h)
		}
	}
	if mod(x+y, 2) == 1 {
		fmt.Fprintln(writer, "black")
		return
	}
	fmt.Fprintln(writer, "white")
}

func mod(x, m int) int {
	return (x%m + m) % m
}

type query struct {
	s string
	k int
}
0