結果

問題 No.351 市松スライドパズル
ユーザー code-devocode-devo
提出日時 2016-03-12 03:26:18
言語 Java21
(openjdk 21)
結果
AC  
実行時間 701 ms / 2,000 ms
コード長 1,524 bytes
コンパイル時間 2,258 ms
コンパイル使用メモリ 77,924 KB
実行使用メモリ 67,508 KB
最終ジャッジ日時 2023-10-25 07:28:17
合計ジャッジ時間 10,582 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 612 ms
66,340 KB
testcase_01 AC 52 ms
52,240 KB
testcase_02 AC 53 ms
53,312 KB
testcase_03 AC 52 ms
52,220 KB
testcase_04 AC 52 ms
53,320 KB
testcase_05 AC 50 ms
53,316 KB
testcase_06 AC 50 ms
53,312 KB
testcase_07 AC 50 ms
53,304 KB
testcase_08 AC 51 ms
53,304 KB
testcase_09 AC 51 ms
53,304 KB
testcase_10 AC 52 ms
53,304 KB
testcase_11 AC 52 ms
53,304 KB
testcase_12 AC 53 ms
53,312 KB
testcase_13 AC 644 ms
66,568 KB
testcase_14 AC 568 ms
62,592 KB
testcase_15 AC 667 ms
67,040 KB
testcase_16 AC 682 ms
66,732 KB
testcase_17 AC 676 ms
66,792 KB
testcase_18 AC 666 ms
66,772 KB
testcase_19 AC 701 ms
67,508 KB
testcase_20 AC 692 ms
66,856 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 {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int n = sc.nextInt();
		boolean[] rs = new boolean[n];
		int[] ks = new int[n];

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

		int x = 0;
		int y = 0;
		for (int i = n - 1; i >= 0; i--) {
			if (rs[i]) {
				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