結果

問題 No.351 市松スライドパズル
ユーザー htensaihtensai
提出日時 2019-11-21 17:01:41
言語 Java19
(openjdk 21)
結果
AC  
実行時間 1,507 ms / 2,000 ms
コード長 757 bytes
コンパイル時間 2,509 ms
コンパイル使用メモリ 71,928 KB
実行使用メモリ 71,920 KB
最終ジャッジ日時 2023-07-31 12:13:01
合計ジャッジ時間 21,251 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,362 ms
70,424 KB
testcase_01 AC 124 ms
56,176 KB
testcase_02 AC 124 ms
55,828 KB
testcase_03 AC 123 ms
56,388 KB
testcase_04 AC 125 ms
55,900 KB
testcase_05 AC 123 ms
56,120 KB
testcase_06 AC 127 ms
55,624 KB
testcase_07 AC 126 ms
56,044 KB
testcase_08 AC 124 ms
55,832 KB
testcase_09 AC 127 ms
56,252 KB
testcase_10 AC 124 ms
56,264 KB
testcase_11 AC 137 ms
55,968 KB
testcase_12 AC 135 ms
56,156 KB
testcase_13 AC 1,489 ms
71,236 KB
testcase_14 AC 1,457 ms
71,596 KB
testcase_15 AC 1,477 ms
71,420 KB
testcase_16 AC 1,486 ms
71,372 KB
testcase_17 AC 1,481 ms
71,920 KB
testcase_18 AC 1,481 ms
71,500 KB
testcase_19 AC 1,491 ms
71,332 KB
testcase_20 AC 1,507 ms
71,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
 	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int n = sc.nextInt();
		char[] types = new char[n];
		int[] idxes = new int[n];
		for (int i = 0; i < n; i++) {
		    types[i] = sc.next().charAt(0);
		    idxes[i] = sc.nextInt();
		}
		int r = 0;
		int c = 0;
		for (int i = n - 1; i >= 0; i--) {
		    if (types[i] == 'R') {
		        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