結果

問題 No.197 手品
ユーザー thorikawathorikawa
提出日時 2015-04-28 23:49:15
言語 Java21
(openjdk 21)
結果
AC  
実行時間 159 ms / 1,000 ms
コード長 1,660 bytes
コンパイル時間 2,128 ms
コンパイル使用メモリ 76,312 KB
実行使用メモリ 57,324 KB
最終ジャッジ日時 2023-09-27 09:25:10
合計ジャッジ時間 10,388 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 146 ms
56,964 KB
testcase_01 AC 150 ms
57,044 KB
testcase_02 AC 147 ms
56,780 KB
testcase_03 AC 144 ms
56,576 KB
testcase_04 AC 149 ms
57,076 KB
testcase_05 AC 149 ms
56,856 KB
testcase_06 AC 146 ms
56,632 KB
testcase_07 AC 146 ms
56,900 KB
testcase_08 AC 152 ms
56,812 KB
testcase_09 AC 116 ms
55,636 KB
testcase_10 AC 155 ms
56,792 KB
testcase_11 AC 146 ms
56,820 KB
testcase_12 AC 144 ms
57,204 KB
testcase_13 AC 153 ms
56,724 KB
testcase_14 AC 147 ms
57,324 KB
testcase_15 AC 146 ms
56,604 KB
testcase_16 AC 151 ms
57,008 KB
testcase_17 AC 154 ms
57,076 KB
testcase_18 AC 159 ms
56,780 KB
testcase_19 AC 155 ms
56,876 KB
testcase_20 AC 148 ms
57,068 KB
testcase_21 AC 152 ms
56,880 KB
testcase_22 AC 150 ms
56,692 KB
testcase_23 AC 110 ms
56,096 KB
testcase_24 AC 145 ms
56,796 KB
testcase_25 AC 149 ms
56,860 KB
testcase_26 AC 155 ms
56,632 KB
testcase_27 AC 150 ms
57,012 KB
testcase_28 AC 145 ms
57,252 KB
testcase_29 AC 153 ms
56,940 KB
testcase_30 AC 150 ms
57,212 KB
testcase_31 AC 110 ms
55,712 KB
testcase_32 AC 113 ms
56,208 KB
testcase_33 AC 150 ms
56,896 KB
testcase_34 AC 145 ms
56,956 KB
testcase_35 AC 153 ms
56,820 KB
testcase_36 AC 154 ms
56,596 KB
testcase_37 AC 141 ms
57,000 KB
testcase_38 AC 145 ms
56,588 KB
testcase_39 AC 145 ms
56,604 KB
testcase_40 AC 148 ms
57,108 KB
testcase_41 AC 153 ms
56,644 KB
testcase_42 AC 144 ms
57,256 KB
testcase_43 AC 142 ms
56,664 KB
testcase_44 AC 147 ms
56,844 KB
testcase_45 AC 146 ms
56,660 KB
testcase_46 AC 153 ms
57,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

/**
 * Created by poly on 11/29/14.
 */
public class Main {
    static Set<String> cand(Set<String> set) {
        Set<String> list = new HashSet<String>();
        for (String s : set) {
            String a = "" + s.charAt(1) + s.charAt(0) + s.charAt(2);
            String b = "" + s.charAt(0) + s.charAt(2) + s.charAt(1);
            list.add(a);
            list.add(b);
        }
        return list;
    }

    public static void main(String[] argv) {
        Scanner scanner = new Scanner(System.in);
        String before = scanner.next();
        int n = scanner.nextInt();
        String after = scanner.next();
        if (n == 0) {
            if (after.equals(before)) {
                System.out.println("FAILURE");
            } else {
                System.out.println("SUCCESS");
            }
            return;
        }
        Set<String> input = new HashSet<String>();
        input.add(before);
        Set<String> one = cand(input);
        if (n == 1) {
            if (one.contains(after)) {
                System.out.println("FAILURE");
            } else {
                System.out.println("SUCCESS");
            }
            return;
        }
        Set<String> two = cand(one);
        if (n % 2 == 0) {
            if (two.contains(after)) {
                System.out.println("FAILURE");
            } else {
                System.out.println("SUCCESS");
            }
            return;
        }
        Set<String> three = cand(two);
        if (three.contains(after)) {
            System.out.println("FAILURE");
        } else {
            System.out.println("SUCCESS");
        }
    }
}
0