結果

問題 No.351 市松スライドパズル
ユーザー code-devocode-devo
提出日時 2016-03-12 02:39:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 714 ms / 2,000 ms
コード長 1,524 bytes
コンパイル時間 2,108 ms
コンパイル使用メモリ 78,164 KB
実行使用メモリ 66,888 KB
最終ジャッジ日時 2023-10-25 07:26:34
合計ジャッジ時間 10,729 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 636 ms
66,396 KB
testcase_01 AC 53 ms
53,312 KB
testcase_02 AC 54 ms
53,312 KB
testcase_03 AC 54 ms
53,308 KB
testcase_04 AC 54 ms
53,312 KB
testcase_05 AC 55 ms
53,316 KB
testcase_06 AC 54 ms
53,316 KB
testcase_07 AC 54 ms
53,316 KB
testcase_08 AC 54 ms
53,308 KB
testcase_09 AC 54 ms
53,324 KB
testcase_10 AC 54 ms
53,308 KB
testcase_11 AC 55 ms
53,332 KB
testcase_12 AC 55 ms
53,316 KB
testcase_13 AC 602 ms
64,652 KB
testcase_14 AC 698 ms
66,888 KB
testcase_15 AC 586 ms
64,684 KB
testcase_16 AC 714 ms
66,784 KB
testcase_17 AC 583 ms
64,612 KB
testcase_18 AC 698 ms
66,828 KB
testcase_19 AC 610 ms
65,216 KB
testcase_20 AC 665 ms
66,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		try (Scanner sc = new Scanner(System.in)) {
			int h = sc.nextInt();
			int w = sc.nextInt();
			int n = sc.nextInt();
			boolean[] rs = new boolean[n];
			int[] ks = new int[n];

			for (int i = 0; i < n; i++) {
				rs[i] = sc.next().charAt(0) == 'R';
				ks[i] = sc.nextInt();
			}

			int x = 0;
			int y = 0;
			for (int i = n - 1; i >= 0; i--) {
				if (rs[i]) {
					if (ks[i] == y) {
						x = (x - 1 + w) % w;
					}
				} else {
					if (ks[i] == x) {
						y = (y - 1 + h) % h;
					}
				}
			}

			System.out.println((x + y) % 2 == 0 ? "white" : "black");
		}
	}
}

class Scanner implements Closeable {
	private BufferedReader br;
	private String[] array;
	private int idx;

	Scanner(InputStream is) {
		InputStreamReader isr = new InputStreamReader(is);
		this.br = new BufferedReader(isr);
		this.array = new String[0];
		this.idx = 0;
	}

	String next() throws IOException {
		if (array.length > idx) {
			return array[idx++];
		} else {
			String line = br.readLine();
			array = line.split(" ");
			idx = 0;
			// 読み込んだ行に何もなかったら・・・ということは考えない。
			return array[idx++];
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	@Override
	public void close() throws IOException {
		br.close();
	}
}
0