結果

問題 No.197 手品
ユーザー mobius_bkstmobius_bkst
提出日時 2015-04-29 13:31:51
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,763 bytes
コンパイル時間 4,169 ms
コンパイル使用メモリ 76,180 KB
実行使用メモリ 49,448 KB
最終ジャッジ日時 2023-09-09 16:05:11
合計ジャッジ時間 7,948 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,300 KB
testcase_01 AC 42 ms
49,356 KB
testcase_02 AC 42 ms
49,172 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 43 ms
49,368 KB
testcase_06 AC 42 ms
49,096 KB
testcase_07 AC 42 ms
49,208 KB
testcase_08 AC 41 ms
49,404 KB
testcase_09 AC 42 ms
49,092 KB
testcase_10 AC 41 ms
49,372 KB
testcase_11 AC 43 ms
49,168 KB
testcase_12 AC 42 ms
49,168 KB
testcase_13 AC 41 ms
49,308 KB
testcase_14 AC 42 ms
49,348 KB
testcase_15 AC 42 ms
49,400 KB
testcase_16 AC 41 ms
49,236 KB
testcase_17 AC 41 ms
49,056 KB
testcase_18 AC 42 ms
49,096 KB
testcase_19 AC 44 ms
49,176 KB
testcase_20 AC 42 ms
49,444 KB
testcase_21 AC 44 ms
49,400 KB
testcase_22 AC 42 ms
49,060 KB
testcase_23 AC 42 ms
49,176 KB
testcase_24 AC 42 ms
49,172 KB
testcase_25 AC 42 ms
49,396 KB
testcase_26 AC 42 ms
49,092 KB
testcase_27 AC 42 ms
49,412 KB
testcase_28 AC 42 ms
49,360 KB
testcase_29 AC 41 ms
49,068 KB
testcase_30 AC 41 ms
49,368 KB
testcase_31 AC 42 ms
49,360 KB
testcase_32 AC 42 ms
49,168 KB
testcase_33 AC 41 ms
49,372 KB
testcase_34 AC 42 ms
49,264 KB
testcase_35 AC 42 ms
49,448 KB
testcase_36 AC 42 ms
49,380 KB
testcase_37 AC 42 ms
49,244 KB
testcase_38 AC 42 ms
49,244 KB
testcase_39 AC 42 ms
49,188 KB
testcase_40 AC 42 ms
47,404 KB
testcase_41 AC 42 ms
49,368 KB
testcase_42 AC 42 ms
49,264 KB
testcase_43 WA -
testcase_44 AC 41 ms
49,236 KB
testcase_45 AC 42 ms
49,344 KB
testcase_46 AC 42 ms
49,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class No197 {

    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(
                    System.in));
            String SBefore = br.readLine();
            int N = Integer.parseInt(br.readLine());
            String SAfter = br.readLine();

            // コインの枚数を数える
            int bCoin = 0;
            int aCoin = 0;
            for (int i = 0; i < args.length; i++) {
                if (SBefore.substring(i, i + 1).equals("o")) {
                    bCoin++;
                }
                if (SAfter.substring(i, i + 1).equals("o")) {
                    aCoin++;
                }
            }

            String str = "FAILURE";
            if (aCoin != bCoin) {
                str = "SUCCESS";
            } else {

                if (N == 0 && !SBefore.equals(SAfter)) {
                    str = "SUCCESS";
                } else if (N == 1) {
                    if (!swap(SBefore, true).equals(SAfter)
                            && !swap(SBefore, false).equals(SAfter)) {
                        str = "SUCCESS";
                    }
                }

            }
            System.out.println(str);
        } catch (Exception e) {
            System.err.println("Error:" + e.getMessage());
        }
    }

    // trueなら左
    // falseなら右
    static String swap(String S, boolean changeSide) {
        char[] c = S.toCharArray();
        char swap = c[1];
        if (changeSide) {
            c[1] = c[0];
            c[0] = swap;
        } else {
            c[1] = c[2];
            c[2] = swap;
        }

        return new String(c);

    }

}
0