結果

問題 No.351 市松スライドパズル
ユーザー ziitaziita
提出日時 2017-06-27 00:07:03
言語 Java19
(openjdk 21)
結果
TLE  
実行時間 -
コード長 3,155 bytes
コンパイル時間 2,645 ms
コンパイル使用メモリ 75,384 KB
実行使用メモリ 255,112 KB
最終ジャッジ日時 2023-07-27 14:14:54
合計ジャッジ時間 8,738 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 502 ms
62,264 KB
testcase_01 AC 48 ms
49,520 KB
testcase_02 AC 48 ms
49,524 KB
testcase_03 AC 48 ms
49,412 KB
testcase_04 AC 47 ms
49,364 KB
testcase_05 AC 48 ms
49,320 KB
testcase_06 AC 49 ms
49,524 KB
testcase_07 AC 47 ms
49,456 KB
testcase_08 AC 46 ms
49,332 KB
testcase_09 AC 47 ms
49,332 KB
testcase_10 AC 47 ms
49,400 KB
testcase_11 AC 49 ms
49,392 KB
testcase_12 AC 48 ms
49,444 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.math.BigDecimal;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int H = in.nextInt();
            int W = in.nextInt();
            int N = in.nextInt();
            boolean board[][] = new boolean[H][W];
            for(int i=0; i<H; i++){
                for(int j=0; j<W; j++){
                    if((i+j%2)%2==0) board[i][j]=true;
                }
            }
            boolean copy[][] = new boolean[H][W];

            for(int i=0; i<N; i++){
                String S = in.next();
                int K = in.nextInt();
                if(S.equals("R")){
                    for(int j=0; j<W; j++){
                        if(j==0) copy[K][j] = board[K][W-1];
                        else copy[K][j] = board[K][j-1];
                    }
                    for(int j=0; j<W; j++){
                        board[K][j] = copy[K][j];
                    }
                }
                else if(S.equals("C")){
                    for(int j=0; j<H; j++){
                        if(j==0) copy[j][K] = board[H-1][K];
                        else copy[j][K] = board[j-1][K];
                    }
                    for(int j=0; j<H; j++){
                        board[j][K] = copy[j][K];
                    }
                }
            }
            if(board[0][0]) out.println("white");
            else out.println("black");
        }
    }


    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}
0