結果

問題 No.351 市松スライドパズル
ユーザー crazybbb3crazybbb3
提出日時 2016-11-28 00:17:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 785 ms / 2,000 ms
コード長 2,168 bytes
コンパイル時間 4,047 ms
コンパイル使用メモリ 77,080 KB
実行使用メモリ 133,248 KB
最終ジャッジ日時 2023-10-25 07:48:49
合計ジャッジ時間 13,739 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 707 ms
132,636 KB
testcase_01 AC 56 ms
53,436 KB
testcase_02 AC 54 ms
53,444 KB
testcase_03 AC 56 ms
53,444 KB
testcase_04 AC 54 ms
53,440 KB
testcase_05 AC 53 ms
53,452 KB
testcase_06 AC 52 ms
52,380 KB
testcase_07 AC 53 ms
53,444 KB
testcase_08 AC 54 ms
53,440 KB
testcase_09 AC 54 ms
53,384 KB
testcase_10 AC 53 ms
53,444 KB
testcase_11 AC 54 ms
53,448 KB
testcase_12 AC 57 ms
53,440 KB
testcase_13 AC 748 ms
132,908 KB
testcase_14 AC 755 ms
132,908 KB
testcase_15 AC 767 ms
132,968 KB
testcase_16 AC 775 ms
133,192 KB
testcase_17 AC 783 ms
133,248 KB
testcase_18 AC 772 ms
133,192 KB
testcase_19 AC 766 ms
133,188 KB
testcase_20 AC 785 ms
131,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        int h = ni();
        int w = ni();
        int n = ni();
        String[] s = new String[n];
        int[] k = new int[n];
        for (int i = 0; i < n; i++) {
            s[i] = ns();
            k[i] = ni();
        }

        int nowi = 0;
        int nowj = 0;

        for (int i = n - 1; i >= 0; i--) {
            if (s[i].equals("R") && k[i] == nowi) {
                nowj = (nowj - 1 + w) % w;
            } else if (s[i].equals("C") && k[i] == nowj) {
                nowi = (nowi - 1 + h) % h;
            }
        }

        out.println((nowi + nowj) % 2 == 0 ? "white" : "black");
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}
0