結果

問題 No.351 市松スライドパズル
ユーザー code-devocode-devo
提出日時 2016-03-12 02:45:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,122 ms / 2,000 ms
コード長 1,570 bytes
コンパイル時間 2,083 ms
コンパイル使用メモリ 77,380 KB
実行使用メモリ 147,400 KB
最終ジャッジ日時 2023-10-25 06:29:08
合計ジャッジ時間 15,043 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,018 ms
145,480 KB
testcase_01 AC 54 ms
52,336 KB
testcase_02 AC 55 ms
53,404 KB
testcase_03 AC 55 ms
53,428 KB
testcase_04 AC 56 ms
53,428 KB
testcase_05 AC 54 ms
52,404 KB
testcase_06 AC 57 ms
53,404 KB
testcase_07 AC 56 ms
53,428 KB
testcase_08 AC 55 ms
53,376 KB
testcase_09 AC 56 ms
53,432 KB
testcase_10 AC 55 ms
52,420 KB
testcase_11 AC 56 ms
53,432 KB
testcase_12 AC 55 ms
53,432 KB
testcase_13 AC 1,112 ms
135,740 KB
testcase_14 AC 1,122 ms
147,400 KB
testcase_15 AC 1,091 ms
134,328 KB
testcase_16 AC 1,109 ms
143,816 KB
testcase_17 AC 1,103 ms
143,800 KB
testcase_18 AC 1,024 ms
138,932 KB
testcase_19 AC 982 ms
134,772 KB
testcase_20 AC 1,052 ms
138,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

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();
			String[] rcs = new String[n];
			int[] ks = new int[n];

			for (int i = 0; i < n; i++) {
				rcs[i] = sc.next();
				ks[i] = sc.nextInt();
			}

			int x = 0;
			int y = 0;
			for (int i = n - 1; i >= 0; i--) {
				if (rcs[i].toCharArray()[0] == 'R') {
					if (ks[i] == y) {
						x--;
						if (x < 0)
							x = w - 1;
					}
				} else {
					if (ks[i] == x) {
						y--;
						if (y < 0)
							y = h - 1;
					}
				}
			}

			System.out.println((x + y) % 2 == 0 ? "white" : "black");
		}
	}
}

class Scanner implements Closeable {
	private BufferedReader br;
	private String[] array;
	private int idx;

	Scanner(InputStream is) {
		InputStreamReader isr = new InputStreamReader(is);
		this.br = new BufferedReader(isr);
		this.array = new String[0];
		this.idx = 0;
	}

	String next() throws IOException {
		if (array.length > idx) {
			return array[idx++];
		} else {
			String line = br.readLine();
			array = line.split(" ");
			idx = 0;
			// 読み込んだ行に何もなかったら・・・ということは考えない。
			return array[idx++];
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	@Override
	public void close() throws IOException {
		br.close();
	}
}
0