結果

問題 No.351 市松スライドパズル
ユーザー code-devocode-devo
提出日時 2016-03-12 01:55:13
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,697 ms / 2,000 ms
コード長 858 bytes
コンパイル時間 3,361 ms
コンパイル使用メモリ 75,064 KB
実行使用メモリ 77,112 KB
最終ジャッジ日時 2023-10-25 06:24:30
合計ジャッジ時間 21,975 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,437 ms
77,112 KB
testcase_01 AC 125 ms
57,592 KB
testcase_02 AC 126 ms
57,556 KB
testcase_03 AC 126 ms
57,356 KB
testcase_04 AC 128 ms
57,584 KB
testcase_05 AC 118 ms
56,284 KB
testcase_06 AC 130 ms
57,684 KB
testcase_07 AC 131 ms
57,604 KB
testcase_08 AC 131 ms
57,800 KB
testcase_09 AC 133 ms
57,764 KB
testcase_10 AC 134 ms
57,640 KB
testcase_11 AC 140 ms
57,784 KB
testcase_12 AC 145 ms
57,512 KB
testcase_13 AC 1,613 ms
76,856 KB
testcase_14 AC 1,659 ms
76,828 KB
testcase_15 AC 1,694 ms
77,100 KB
testcase_16 AC 1,650 ms
76,908 KB
testcase_17 AC 1,648 ms
76,920 KB
testcase_18 AC 1,626 ms
77,092 KB
testcase_19 AC 1,697 ms
76,708 KB
testcase_20 AC 1,683 ms
76,680 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 = (x - 1 + w) % w;
					}
				} else {
					if (ks[i] == x) {
						y = (y - 1 + h) % h;
					}
				}

				// 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