結果

問題 No.351 市松スライドパズル
ユーザー code-devo
提出日時 2016-03-11 23:07:38
言語 Java
(openjdk 23)
結果
TLE  
実行時間 -
コード長 1,161 bytes
コンパイル時間 2,346 ms
コンパイル使用メモリ 79,128 KB
実行使用メモリ 479,224 KB
最終ジャッジ日時 2024-09-25 01:14:36
合計ジャッジ時間 11,504 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 9 TLE * 1 -- * 7
権限があれば一括ダウンロードができます

ソースコード

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