結果

問題 No.197 手品
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-12-09 19:22:18
言語 Java21
(openjdk 21)
結果
AC  
実行時間 117 ms / 1,000 ms
コード長 1,339 bytes
コンパイル時間 1,740 ms
コンパイル使用メモリ 74,076 KB
実行使用メモリ 58,060 KB
最終ジャッジ日時 2023-09-27 09:43:25
合計ジャッジ時間 8,571 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 107 ms
55,736 KB
testcase_01 AC 109 ms
54,504 KB
testcase_02 AC 114 ms
55,844 KB
testcase_03 AC 105 ms
55,784 KB
testcase_04 AC 108 ms
55,900 KB
testcase_05 AC 107 ms
56,084 KB
testcase_06 AC 111 ms
56,080 KB
testcase_07 AC 114 ms
55,800 KB
testcase_08 AC 115 ms
55,576 KB
testcase_09 AC 115 ms
56,476 KB
testcase_10 AC 111 ms
56,124 KB
testcase_11 AC 108 ms
56,076 KB
testcase_12 AC 110 ms
56,144 KB
testcase_13 AC 112 ms
55,876 KB
testcase_14 AC 112 ms
56,800 KB
testcase_15 AC 111 ms
55,728 KB
testcase_16 AC 115 ms
56,168 KB
testcase_17 AC 112 ms
55,760 KB
testcase_18 AC 109 ms
55,768 KB
testcase_19 AC 106 ms
55,792 KB
testcase_20 AC 114 ms
58,060 KB
testcase_21 AC 109 ms
56,112 KB
testcase_22 AC 112 ms
56,156 KB
testcase_23 AC 117 ms
56,048 KB
testcase_24 AC 113 ms
55,968 KB
testcase_25 AC 111 ms
56,024 KB
testcase_26 AC 111 ms
55,836 KB
testcase_27 AC 112 ms
55,904 KB
testcase_28 AC 111 ms
56,188 KB
testcase_29 AC 111 ms
55,740 KB
testcase_30 AC 114 ms
56,188 KB
testcase_31 AC 110 ms
55,884 KB
testcase_32 AC 111 ms
55,780 KB
testcase_33 AC 109 ms
56,016 KB
testcase_34 AC 105 ms
56,148 KB
testcase_35 AC 110 ms
56,156 KB
testcase_36 AC 109 ms
54,056 KB
testcase_37 AC 112 ms
56,000 KB
testcase_38 AC 110 ms
56,036 KB
testcase_39 AC 115 ms
55,932 KB
testcase_40 AC 115 ms
55,872 KB
testcase_41 AC 112 ms
56,076 KB
testcase_42 AC 110 ms
55,476 KB
testcase_43 AC 111 ms
55,580 KB
testcase_44 AC 113 ms
55,796 KB
testcase_45 AC 111 ms
55,924 KB
testcase_46 AC 113 ms
55,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String Sbefore = sc.next();
        int N = sc.nextInt();
        String Safter = sc.next();
        String ans = judge(Sbefore, Safter, N);
        System.out.println(ans);
        
    }
    static String judge(String x, String y, int N){
        String ans = "SUCCESS";
        int a=0;
        int b=0;
        for(int i=0; i<3; i++){
            if(x.charAt(i)=='o')a++;
        }
        for(int i=0; i<3; i++){
            if(y.charAt(i)=='o')b++;
        }
        if(a==b){
            if(N>=2){
                ans="FAILURE";
            }else if(N==0){
                if(x.equals(y)){
                    ans="FAILURE";
                }
            }else{
                char [] c = x.toCharArray();
                char [] p = new char [3];
                for(int i=0; i<3; i++){
                    if(i==1)continue;
                    p[i]=c[i];
                    p[(i+1)%3]=c[(i+2)%3];
                    p[(i+2)%3]=c[(i+1)%3];
                    String t = String.valueOf(p);
                    if(t.equals(y)){
                        ans="FAILURE";
                        break;
                    }
                }
            }
        }
        return ans;
    }
}
0