結果

問題 No.351 市松スライドパズル
ユーザー TatsuDXTatsuDX
提出日時 2016-10-16 20:54:59
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,442 ms / 2,000 ms
コード長 669 bytes
コンパイル時間 3,225 ms
コンパイル使用メモリ 74,336 KB
実行使用メモリ 67,488 KB
最終ジャッジ日時 2023-08-14 14:25:43
合計ジャッジ時間 22,087 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,322 ms
54,172 KB
testcase_01 AC 116 ms
39,512 KB
testcase_02 AC 114 ms
39,324 KB
testcase_03 AC 117 ms
39,364 KB
testcase_04 AC 116 ms
39,712 KB
testcase_05 AC 116 ms
39,616 KB
testcase_06 AC 115 ms
39,728 KB
testcase_07 AC 118 ms
39,084 KB
testcase_08 AC 118 ms
39,440 KB
testcase_09 AC 121 ms
39,760 KB
testcase_10 AC 119 ms
40,044 KB
testcase_11 AC 128 ms
39,256 KB
testcase_12 AC 129 ms
39,740 KB
testcase_13 AC 1,411 ms
55,792 KB
testcase_14 AC 1,399 ms
55,752 KB
testcase_15 AC 1,442 ms
56,072 KB
testcase_16 AC 1,432 ms
55,804 KB
testcase_17 AC 1,434 ms
56,048 KB
testcase_18 AC 1,413 ms
67,488 KB
testcase_19 AC 1,415 ms
55,916 KB
testcase_20 AC 1,434 ms
55,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Test {
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int h = sc.nextInt(), w = sc.nextInt(), n = sc.nextInt();
		int x = 0, y = 0;
		int[] m = new int[n];
		char[] c = new char[n];
		for(int i = 0; i < n; i++){
			c[i] = sc.next().charAt(0);
			m[i] = sc.nextInt();
		}
		for(int i = n-1; i >= 0; i--){
			if(y == m[i] && c[i] == 'R'){
				x--;
				if(x < 0){
					x += w;
				}
			} else if(x == m[i] && c[i] == 'C'){
				y--;
				if(y < 0){
					y += h;
				}
			}
		}
		if((x + y) % 2 == 0){
			System.out.println("white");
		} else {
			System.out.println("black");
		}
	}
}
0