結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 634 ms
66,360 KB
testcase_01 AC 53 ms
53,380 KB
testcase_02 AC 54 ms
53,360 KB
testcase_03 AC 53 ms
53,384 KB
testcase_04 AC 53 ms
53,376 KB
testcase_05 AC 54 ms
53,384 KB
testcase_06 AC 54 ms
53,376 KB
testcase_07 AC 53 ms
53,384 KB
testcase_08 AC 53 ms
53,384 KB
testcase_09 AC 53 ms
53,376 KB
testcase_10 AC 54 ms
53,384 KB
testcase_11 AC 54 ms
53,384 KB
testcase_12 AC 53 ms
53,388 KB
testcase_13 AC 708 ms
67,136 KB
testcase_14 AC 699 ms
67,352 KB
testcase_15 AC 577 ms
64,760 KB
testcase_16 AC 715 ms
67,000 KB
testcase_17 AC 696 ms
67,084 KB
testcase_18 AC 707 ms
67,204 KB
testcase_19 AC 706 ms
67,136 KB
testcase_20 AC 692 ms
67,432 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();
			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