結果

問題 No.197 手品
ユーザー kenkooookenkoooo
提出日時 2015-04-28 23:43:49
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,579 bytes
コンパイル時間 2,196 ms
コンパイル使用メモリ 73,452 KB
実行使用メモリ 56,572 KB
最終ジャッジ日時 2023-09-09 14:23:28
合計ジャッジ時間 9,463 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
56,172 KB
testcase_01 AC 116 ms
56,256 KB
testcase_02 AC 117 ms
53,860 KB
testcase_03 AC 117 ms
55,744 KB
testcase_04 AC 119 ms
56,108 KB
testcase_05 AC 120 ms
55,596 KB
testcase_06 AC 121 ms
56,276 KB
testcase_07 AC 119 ms
56,440 KB
testcase_08 AC 119 ms
55,872 KB
testcase_09 AC 119 ms
55,924 KB
testcase_10 AC 119 ms
56,096 KB
testcase_11 AC 119 ms
55,636 KB
testcase_12 AC 118 ms
56,424 KB
testcase_13 AC 119 ms
56,148 KB
testcase_14 AC 119 ms
55,912 KB
testcase_15 AC 120 ms
55,996 KB
testcase_16 AC 118 ms
55,804 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 119 ms
56,316 KB
testcase_21 AC 118 ms
55,888 KB
testcase_22 AC 123 ms
56,572 KB
testcase_23 AC 122 ms
55,892 KB
testcase_24 AC 119 ms
56,136 KB
testcase_25 AC 122 ms
55,704 KB
testcase_26 AC 121 ms
55,752 KB
testcase_27 AC 121 ms
55,744 KB
testcase_28 AC 119 ms
55,744 KB
testcase_29 AC 121 ms
55,804 KB
testcase_30 AC 125 ms
55,820 KB
testcase_31 AC 120 ms
55,372 KB
testcase_32 AC 119 ms
56,052 KB
testcase_33 AC 121 ms
55,756 KB
testcase_34 AC 119 ms
56,124 KB
testcase_35 AC 121 ms
56,392 KB
testcase_36 AC 118 ms
56,104 KB
testcase_37 WA -
testcase_38 AC 119 ms
56,264 KB
testcase_39 AC 118 ms
55,764 KB
testcase_40 AC 118 ms
56,100 KB
testcase_41 AC 125 ms
55,548 KB
testcase_42 AC 120 ms
55,808 KB
testcase_43 AC 119 ms
56,156 KB
testcase_44 WA -
testcase_45 AC 118 ms
56,312 KB
testcase_46 AC 119 ms
55,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String before = sc.next();
		int N = sc.nextInt();
		String after = sc.next();
		sc.close();

		int bCoins = 0;
		int aCoins = 0;
		for (int i = 0; i < 3; i++) {
			if (before.charAt(i) == 'o') {
				bCoins++;
			}
			if (after.charAt(i) == 'o') {
				aCoins++;
			}
		}
		if (aCoins != bCoins) {
			System.out.println("SUCCESS");
			return;
		}

		if (aCoins == 0 || aCoins == 3) {
			System.out.println("FAILURE");
			return;
		}
		if (aCoins == 1) {
			before = before.replaceAll("o", "1").replaceAll("x", "2");
			after = after.replaceAll("o", "1").replaceAll("x", "2");
		} else {
			before = before.replaceAll("o", "2").replaceAll("x", "1");
			after = after.replaceAll("o", "2").replaceAll("x", "1");
		}

		if (before.equals(after)) {
			if (N % 2 == 0) {
				System.out.println("FAILURE");
				return;
			} else if (before.equals("122") || before.equals("221")) {
				System.out.println("FAILURE");
				return;
			}
			System.out.println("SUCCESS");
			return;
		}

		if (before.equals("122") || before.equals("221")) {
			if (after.equals("212")) {
				if (N > 0) {
					System.out.println("FAILURE");
					return;
				}
				System.out.println("SUCCESS");
				return;
			} else {
				if (N > 1) {
					System.out.println("FAILURE");
					return;
				}
				System.out.println("SUCCESS");
				return;
			}
		} else {
			if (N > 0) {
				System.out.println("FAILURE");
				return;
			}
			System.out.println("SUCCESS");
			return;
		}

	}

}
0