結果

問題 No.351 市松スライドパズル
ユーザー code-devocode-devo
提出日時 2016-03-11 23:07:38
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,161 bytes
コンパイル時間 3,717 ms
コンパイル使用メモリ 79,120 KB
実行使用メモリ 480,120 KB
最終ジャッジ日時 2023-10-25 05:50:10
合計ジャッジ時間 13,784 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,514 ms
72,684 KB
testcase_01 AC 135 ms
57,656 KB
testcase_02 AC 134 ms
57,596 KB
testcase_03 AC 136 ms
57,560 KB
testcase_04 AC 137 ms
57,632 KB
testcase_05 AC 140 ms
57,564 KB
testcase_06 AC 135 ms
57,544 KB
testcase_07 AC 137 ms
57,468 KB
testcase_08 AC 134 ms
57,504 KB
testcase_09 AC 138 ms
57,628 KB
testcase_10 AC 140 ms
57,568 KB
testcase_11 AC 148 ms
57,568 KB
testcase_12 AC 146 ms
57,656 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

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();

			Color[][] map = new Color[h][w];
			for (int y = 0; y < h; y++) {
				for (int x = 0; x < w; x++) {
					map[y][x] = (x + y) % 2 == 0 ? Color.white : Color.black;
				}
			}

			int n = sc.nextInt();
			for (int i = 0; i < n; i++) {
				String s = sc.next();
				int k = sc.nextInt();

				switch (s) {
				case "R": {
					Color t = map[k][w - 1];
					for (int x = w - 1; x >= 1; x--) {
						map[k][x] = map[k][x - 1];
					}
					map[k][0] = t;
					break;
				}
				case "C": {
					Color t = map[h - 1][k];
					for (int y = h - 1; y >= 1; y--) {
						map[y][k] = map[y - 1][k];
					}
					map[0][k] = t;
					break;
				}
				}
			}

			System.out.println(map[0][0]);
		}
	}

//	static void print(Color[][] map) {
//		for (int y = 0; y < map.length; y++) {
//			for (int x = 0; x < map[y].length; x++) {
//				System.err.print(map[y][x]);
//				System.err.print(" ");
//			}
//			System.err.println();
//		}
//	}
}

enum Color {
	black, white;
}
0