結果

問題 No.351 市松スライドパズル
ユーザー htensaihtensai
提出日時 2019-11-21 17:10:34
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 992 bytes
コンパイル時間 2,172 ms
コンパイル使用メモリ 78,192 KB
実行使用メモリ 51,576 KB
最終ジャッジ日時 2024-04-18 13:43:54
合計ジャッジ時間 8,580 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 327 ms
51,308 KB
testcase_01 AC 55 ms
37,112 KB
testcase_02 AC 56 ms
37,040 KB
testcase_03 AC 57 ms
36,848 KB
testcase_04 AC 58 ms
36,896 KB
testcase_05 AC 56 ms
37,060 KB
testcase_06 AC 54 ms
36,912 KB
testcase_07 AC 56 ms
36,664 KB
testcase_08 AC 55 ms
36,844 KB
testcase_09 AC 58 ms
37,076 KB
testcase_10 AC 57 ms
37,084 KB
testcase_11 WA -
testcase_12 AC 56 ms
36,916 KB
testcase_13 AC 394 ms
49,992 KB
testcase_14 AC 391 ms
49,920 KB
testcase_15 AC 395 ms
49,384 KB
testcase_16 AC 409 ms
51,576 KB
testcase_17 AC 401 ms
50,552 KB
testcase_18 AC 367 ms
49,876 KB
testcase_19 AC 358 ms
49,752 KB
testcase_20 AC 374 ms
49,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
 	public static void main (String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] first = br.readLine().split(" ", 2);
		int h = Integer.parseInt(first[0]);
		int w = Integer.parseInt(first[0]);
		int n = Integer.parseInt(br.readLine());
		boolean[] isR = new boolean[n];
		int[] idxes = new int[n];
		for (int i = 0; i < n; i++) {
		    String line = br.readLine();
		    isR[i] = line.charAt(0) == 'R';
		    idxes[i] = Integer.parseInt(line.substring(2, line.length()));
		}
		int r = 0;
		int c = 0;
		for (int i = n - 1; i >= 0; i--) {
		    if (isR[i]) {
		        if (idxes[i] == r) {
		            c = (c + w - 1) % w;
		        }
		    } else {
		        if (idxes[i] == c) {
		            r = (r + h - 1) % h;
		        }
		    }
		}
		if (c % 2 == 0 ^ r % 2 == 0) {
		    System.out.println("black");
		} else {
		    System.out.println("white");
		}
	}
}
0