結果

問題 No.351 市松スライドパズル
ユーザー code-devocode-devo
提出日時 2016-03-12 01:52:31
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,785 ms / 2,000 ms
コード長 896 bytes
コンパイル時間 2,539 ms
コンパイル使用メモリ 74,832 KB
実行使用メモリ 77,256 KB
最終ジャッジ日時 2023-10-25 06:23:06
合計ジャッジ時間 22,847 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,608 ms
76,876 KB
testcase_01 AC 138 ms
57,584 KB
testcase_02 AC 137 ms
57,520 KB
testcase_03 AC 136 ms
57,532 KB
testcase_04 AC 135 ms
57,504 KB
testcase_05 AC 136 ms
57,584 KB
testcase_06 AC 135 ms
57,552 KB
testcase_07 AC 138 ms
57,776 KB
testcase_08 AC 136 ms
57,780 KB
testcase_09 AC 139 ms
57,560 KB
testcase_10 AC 141 ms
57,744 KB
testcase_11 AC 150 ms
57,688 KB
testcase_12 AC 152 ms
57,856 KB
testcase_13 AC 1,732 ms
76,832 KB
testcase_14 AC 1,689 ms
76,880 KB
testcase_15 AC 1,740 ms
77,004 KB
testcase_16 AC 1,785 ms
77,040 KB
testcase_17 AC 1,671 ms
77,256 KB
testcase_18 AC 1,738 ms
77,152 KB
testcase_19 AC 1,721 ms
76,896 KB
testcase_20 AC 1,740 ms
76,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// http://yukicoder.me/submissions/81063 を参考に、Scannerで再度書いてみる。

import java.util.Scanner;

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--;
						if (x < 0)
							x = w - 1;
					}
				} else {
					if (ks[i] == x) {
						y--;
						if (y < 0)
							y = h - 1;
					}
				}

				// System.err.println(String.format("%b %d (%d, %d)", rs[i], ks[i], x, y));
			}

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