結果

問題 No.351 市松スライドパズル
ユーザー code-devocode-devo
提出日時 2016-03-12 00:11:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 855 ms / 2,000 ms
コード長 1,063 bytes
コンパイル時間 2,108 ms
コンパイル使用メモリ 78,212 KB
実行使用メモリ 167,560 KB
最終ジャッジ日時 2023-10-25 07:21:56
合計ジャッジ時間 12,392 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 758 ms
158,224 KB
testcase_01 AC 52 ms
53,260 KB
testcase_02 AC 51 ms
53,264 KB
testcase_03 AC 51 ms
53,276 KB
testcase_04 AC 52 ms
53,264 KB
testcase_05 AC 51 ms
53,260 KB
testcase_06 AC 51 ms
53,272 KB
testcase_07 AC 51 ms
53,264 KB
testcase_08 AC 54 ms
53,260 KB
testcase_09 AC 51 ms
53,268 KB
testcase_10 AC 50 ms
53,260 KB
testcase_11 AC 51 ms
53,264 KB
testcase_12 AC 51 ms
53,268 KB
testcase_13 AC 810 ms
166,176 KB
testcase_14 AC 802 ms
164,512 KB
testcase_15 AC 825 ms
167,548 KB
testcase_16 AC 798 ms
165,476 KB
testcase_17 AC 839 ms
165,496 KB
testcase_18 AC 855 ms
167,560 KB
testcase_19 AC 824 ms
165,512 KB
testcase_20 AC 798 ms
165,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		try (InputStreamReader isr = new InputStreamReader(System.in)) {
			StringBuilder sb = new StringBuilder();

			char[] cbuf = new char[4000];
			int size;
			while ((size = isr.read(cbuf)) >= 0) {
				sb.append(cbuf, 0, size);
			}

			String[] lines = sb.toString().split("\n");
			String[] ary = lines[0].trim().split(" ");
			int h = Integer.parseInt(ary[0]);
			int w = Integer.parseInt(ary[1]);

			int x = 0;
			int y = 0;
			for (int i = lines.length - 1; i >= 2; i--) {
				ary = lines[i].trim().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