結果

問題 No.351 市松スライドパズル
ユーザー YamaKasa
提出日時 2018-09-17 15:28:13
言語 Java
(openjdk 23)
結果
AC  
実行時間 1,588 ms / 2,000 ms
コード長 773 bytes
コンパイル時間 1,947 ms
コンパイル使用メモリ 77,404 KB
実行使用メモリ 141,212 KB
最終ジャッジ日時 2024-07-18 07:41:50
合計ジャッジ時間 20,204 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

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