結果

問題 No.197 手品
ユーザー Grenache
提出日時 2016-02-15 20:05:57
言語 Java
(openjdk 23)
結果
AC  
実行時間 156 ms / 1,000 ms
コード長 1,707 bytes
コンパイル時間 4,071 ms
コンパイル使用メモリ 77,696 KB
実行使用メモリ 54,704 KB
最終ジャッジ日時 2024-07-20 03:47:08
合計ジャッジ時間 12,347 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder197 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        char[] be = sc.next().toCharArray();
        int n = sc.nextInt();
        char[] af = sc.next().toCharArray();

        int bcnt = 0;
        int acnt = 0;
        for (int i = 0; i < 3; i++) {
        	if (be[i] == 'o') {
        		bcnt++;
        	}
        	if (af[i] == 'o') {
        		acnt++;
        	}
        }

        if (bcnt != acnt) {
            System.out.println("SUCCESS");
        } else {
        	if (bcnt == 0 || bcnt == 3) {
                System.out.println("FAILURE");
        	} else {
        		String bs = new String(be);
        		String as = new String(af);
        		if (n == 0) {
            		if (bs.equals(as)) {
                        System.out.println("FAILURE");
            		} else {
                        System.out.println("SUCCESS");
            		}
        		} else if (n == 1) {
        			if (
        					(bs.equals("oxo") && as.charAt(1) == 'o')
        					|| (bs.equals("xox") && as.charAt(1) == 'x')
        					|| (bs.equals("xox") && as.charAt(1) == 'x')
        					|| (bs.equals("xxo") && as.charAt(0) != 'o')
        					|| (bs.equals("oxx") && as.charAt(2) != 'o')
        					|| (bs.equals("oox") && as.charAt(0) != 'x')
        					|| (bs.equals("xoo") && as.charAt(2) != 'x')
        					) {
                        System.out.println("FAILURE");
            		} else {
                        System.out.println("SUCCESS");
            		}
        		} else {
                    System.out.println("FAILURE");
        		}
        	}
        }

        sc.close();
    }
}
0