結果

問題 No.351 市松スライドパズル
ユーザー code-devocode-devo
提出日時 2016-03-12 03:21:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 763 ms / 2,000 ms
コード長 1,424 bytes
コンパイル時間 2,323 ms
コンパイル使用メモリ 78,252 KB
実行使用メモリ 68,116 KB
最終ジャッジ日時 2023-10-25 07:27:44
合計ジャッジ時間 12,327 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 662 ms
66,892 KB
testcase_01 AC 56 ms
53,380 KB
testcase_02 AC 55 ms
52,344 KB
testcase_03 AC 56 ms
51,340 KB
testcase_04 AC 55 ms
51,344 KB
testcase_05 AC 57 ms
53,388 KB
testcase_06 AC 56 ms
53,392 KB
testcase_07 AC 58 ms
53,412 KB
testcase_08 AC 55 ms
53,380 KB
testcase_09 AC 56 ms
53,380 KB
testcase_10 AC 55 ms
53,388 KB
testcase_11 AC 56 ms
53,392 KB
testcase_12 AC 56 ms
53,400 KB
testcase_13 AC 761 ms
67,720 KB
testcase_14 AC 754 ms
67,992 KB
testcase_15 AC 751 ms
67,744 KB
testcase_16 AC 758 ms
67,640 KB
testcase_17 AC 761 ms
67,520 KB
testcase_18 AC 749 ms
67,696 KB
testcase_19 AC 763 ms
68,116 KB
testcase_20 AC 758 ms
65,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Iterator;

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 {
	BufferedReader br;
	Iterator<String> it;

	Scanner(InputStream in) {
		br = new BufferedReader(new InputStreamReader(in));
	}

	String next() throws RuntimeException {
		try {
			if (it == null || !it.hasNext()) {
				it = Arrays.asList(br.readLine().split(" ")).iterator();
			}
			return it.next();
		} catch (IOException e) {
			throw new IllegalStateException();
		}
	}

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

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