結果

問題 No.351 市松スライドパズル
ユーザー YamaKasaYamaKasa
提出日時 2018-09-17 15:28:13
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,672 ms / 2,000 ms
コード長 773 bytes
コンパイル時間 3,761 ms
コンパイル使用メモリ 73,724 KB
実行使用メモリ 154,524 KB
最終ジャッジ日時 2023-09-25 09:25:03
合計ジャッジ時間 23,673 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,477 ms
150,720 KB
testcase_01 AC 125 ms
55,808 KB
testcase_02 AC 125 ms
55,428 KB
testcase_03 AC 127 ms
55,672 KB
testcase_04 AC 125 ms
55,680 KB
testcase_05 AC 126 ms
55,712 KB
testcase_06 AC 126 ms
55,936 KB
testcase_07 AC 127 ms
55,616 KB
testcase_08 AC 123 ms
55,936 KB
testcase_09 AC 126 ms
55,860 KB
testcase_10 AC 128 ms
55,808 KB
testcase_11 AC 132 ms
56,028 KB
testcase_12 AC 133 ms
56,052 KB
testcase_13 AC 1,597 ms
146,384 KB
testcase_14 AC 1,524 ms
144,144 KB
testcase_15 AC 1,606 ms
151,324 KB
testcase_16 AC 1,663 ms
154,524 KB
testcase_17 AC 1,645 ms
151,144 KB
testcase_18 AC 1,630 ms
151,144 KB
testcase_19 AC 1,558 ms
150,688 KB
testcase_20 AC 1,672 ms
150,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int H = scan.nextInt();
		int W = scan.nextInt();
		int N = scan.nextInt();
		String []S = new String[N];
		int []K = new int[N];
		for(int i = 0; i < N; i++) {
			S[i] = scan.next();
			K[i] = Integer.parseInt(scan.next());
		}
		scan.close();
		int r = 0;
		int c = 0;
		for(int i = N - 1; i >= 0; i--) {
			if(S[i].equals("R") && r == K[i]) {
				if(c == 0) {
					c = W - 1;
				}else {
					c = c - 1;
				}
			}else if(S[i].equals("C") && c == K[i]) {
				if(r == 0) {
					r = H - 1;
				}else {
					r = r - 1;
				}
			}
		}
		if((r + c) % 2 == 0) {
			System.out.println("white");
		}else {
			System.out.println("black");
		}
	}
}
0