結果

問題 No.351 市松スライドパズル
ユーザー code-devocode-devo
提出日時 2016-03-11 23:53:06
言語 Java21
(openjdk 21)
結果
AC  
実行時間 868 ms / 2,000 ms
コード長 1,289 bytes
コンパイル時間 2,255 ms
コンパイル使用メモリ 78,448 KB
実行使用メモリ 147,208 KB
最終ジャッジ日時 2023-10-25 07:19:02
合計ジャッジ時間 12,576 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 782 ms
147,008 KB
testcase_01 AC 54 ms
53,372 KB
testcase_02 AC 53 ms
53,364 KB
testcase_03 AC 54 ms
53,376 KB
testcase_04 AC 54 ms
53,364 KB
testcase_05 AC 55 ms
53,396 KB
testcase_06 AC 54 ms
53,372 KB
testcase_07 AC 55 ms
53,380 KB
testcase_08 AC 54 ms
53,380 KB
testcase_09 AC 54 ms
53,364 KB
testcase_10 AC 54 ms
53,372 KB
testcase_11 AC 55 ms
53,372 KB
testcase_12 AC 55 ms
53,372 KB
testcase_13 AC 868 ms
146,768 KB
testcase_14 AC 832 ms
146,608 KB
testcase_15 AC 850 ms
146,752 KB
testcase_16 AC 834 ms
147,208 KB
testcase_17 AC 847 ms
146,744 KB
testcase_18 AC 855 ms
146,244 KB
testcase_19 AC 854 ms
146,796 KB
testcase_20 AC 831 ms
147,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// JavaでTLE叩き出して恥ずかしい。

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
	public static void main(String[] args) throws Exception {
		try (InputStreamReader isr = new InputStreamReader(System.in); //
				BufferedReader br = new BufferedReader(isr)) {
			String line = br.readLine();
			String[] ary = line.split(" ");
			int h = Integer.parseInt(ary[0]);
			int w = Integer.parseInt(ary[1]);
			// System.err.println(String.format("h:%d w:%d", h, w));

			int n = Integer.parseInt(br.readLine());
			// System.err.println(String.format("n:%d", n));

			List<String> list = new ArrayList<>();
			for (int i = 0; i < n; i++) {
				list.add(br.readLine());
			}

			int x = 0;
			int y = 0;
			for (int i = list.size() - 1; i >= 0; i--) {
				String sk = list.get(i);
				ary = sk.split(" ");
				String s = ary[0];
				int k = Integer.parseInt(ary[1]);
				if ("R".equals(s) && k == y) {
					x--;
					if (x < 0)
						x = w - 1;
				} else if ("C".equals(s) && k == x) {
					y--;
					if (y < 0)
						y = h - 1;
				}
				// System.err.println(String.format("%s %d (%d, %d)", s, k, x,
				// y));
			}

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

	}
}
0