結果

問題 No.351 市松スライドパズル
ユーザー htensaihtensai
提出日時 2019-11-21 17:01:41
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,656 ms / 2,000 ms
コード長 757 bytes
コンパイル時間 1,994 ms
コンパイル使用メモリ 74,964 KB
実行使用メモリ 75,752 KB
最終ジャッジ日時 2024-04-18 12:31:42
合計ジャッジ時間 21,773 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,544 ms
64,036 KB
testcase_01 AC 128 ms
41,484 KB
testcase_02 AC 124 ms
40,332 KB
testcase_03 AC 126 ms
41,300 KB
testcase_04 AC 131 ms
41,340 KB
testcase_05 AC 133 ms
41,152 KB
testcase_06 AC 117 ms
41,196 KB
testcase_07 AC 128 ms
41,148 KB
testcase_08 AC 124 ms
41,344 KB
testcase_09 AC 128 ms
41,424 KB
testcase_10 AC 127 ms
41,236 KB
testcase_11 AC 136 ms
41,620 KB
testcase_12 AC 143 ms
41,704 KB
testcase_13 AC 1,640 ms
57,340 KB
testcase_14 AC 1,602 ms
57,364 KB
testcase_15 AC 1,632 ms
63,948 KB
testcase_16 AC 1,440 ms
64,564 KB
testcase_17 AC 1,639 ms
57,572 KB
testcase_18 AC 1,656 ms
64,076 KB
testcase_19 AC 1,562 ms
75,752 KB
testcase_20 AC 1,573 ms
64,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
 	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int n = sc.nextInt();
		char[] types = new char[n];
		int[] idxes = new int[n];
		for (int i = 0; i < n; i++) {
		    types[i] = sc.next().charAt(0);
		    idxes[i] = sc.nextInt();
		}
		int r = 0;
		int c = 0;
		for (int i = n - 1; i >= 0; i--) {
		    if (types[i] == 'R') {
		        if (idxes[i] == r) {
		            c = (c + w - 1) % w;
		        }
		    } else {
		        if (idxes[i] == c) {
		            r = (r + h - 1) % h;
		        }
		    }
		}
		if (c % 2 == 0 ^ r % 2 == 0) {
		    System.out.println("black");
		} else {
		    System.out.println("white");
		}
	}
}
0