結果

問題 No.351 市松スライドパズル
ユーザー code-devocode-devo
提出日時 2016-03-12 00:19:14
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,054 bytes
コンパイル時間 2,624 ms
コンパイル使用メモリ 84,828 KB
実行使用メモリ 184,572 KB
最終ジャッジ日時 2023-10-25 06:16:25
合計ジャッジ時間 9,717 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

// 時間切れ

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(1_000_000);

			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)) {
					if (k == y) {
						x--;
						if (x < 0)
							x = w - 1;
					}
				} else {
					if (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