結果

問題 No.197 手品
ユーザー kenkooookenkoooo
提出日時 2015-04-28 23:52:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 117 ms / 1,000 ms
コード長 1,581 bytes
コンパイル時間 2,035 ms
コンパイル使用メモリ 73,792 KB
実行使用メモリ 57,756 KB
最終ジャッジ日時 2023-09-27 09:25:51
合計ジャッジ時間 8,572 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
55,868 KB
testcase_01 AC 110 ms
55,796 KB
testcase_02 AC 107 ms
55,976 KB
testcase_03 AC 112 ms
55,524 KB
testcase_04 AC 113 ms
55,960 KB
testcase_05 AC 106 ms
56,144 KB
testcase_06 AC 108 ms
56,008 KB
testcase_07 AC 111 ms
56,280 KB
testcase_08 AC 111 ms
55,648 KB
testcase_09 AC 113 ms
56,284 KB
testcase_10 AC 112 ms
56,040 KB
testcase_11 AC 112 ms
56,000 KB
testcase_12 AC 111 ms
55,572 KB
testcase_13 AC 111 ms
56,084 KB
testcase_14 AC 109 ms
55,708 KB
testcase_15 AC 113 ms
57,756 KB
testcase_16 AC 109 ms
55,976 KB
testcase_17 AC 111 ms
56,052 KB
testcase_18 AC 113 ms
55,604 KB
testcase_19 AC 112 ms
55,896 KB
testcase_20 AC 110 ms
56,044 KB
testcase_21 AC 110 ms
55,856 KB
testcase_22 AC 109 ms
55,648 KB
testcase_23 AC 117 ms
55,644 KB
testcase_24 AC 109 ms
56,112 KB
testcase_25 AC 117 ms
56,140 KB
testcase_26 AC 115 ms
56,072 KB
testcase_27 AC 110 ms
55,824 KB
testcase_28 AC 110 ms
55,788 KB
testcase_29 AC 109 ms
55,864 KB
testcase_30 AC 112 ms
55,992 KB
testcase_31 AC 109 ms
56,196 KB
testcase_32 AC 112 ms
55,908 KB
testcase_33 AC 110 ms
55,688 KB
testcase_34 AC 109 ms
56,036 KB
testcase_35 AC 114 ms
55,972 KB
testcase_36 AC 113 ms
55,728 KB
testcase_37 AC 113 ms
55,480 KB
testcase_38 AC 112 ms
54,276 KB
testcase_39 AC 112 ms
56,276 KB
testcase_40 AC 113 ms
55,980 KB
testcase_41 AC 113 ms
55,996 KB
testcase_42 AC 112 ms
55,892 KB
testcase_43 AC 109 ms
56,276 KB
testcase_44 AC 109 ms
56,124 KB
testcase_45 AC 110 ms
55,868 KB
testcase_46 AC 112 ms
55,784 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 == 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 (aCoins != bCoins) {
			System.out.println("SUCCESS");
			return;
		}

		if (aCoins == 0 || aCoins == 3) {
			System.out.println("FAILURE");
			return;
		}

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

			}
		} else {
			if (before.equals(after)) {
				if (N == 1) {
					System.out.println("SUCCESS");
					return;
				}
				System.out.println("FAILURE");
				return;
			} else {
				if (N == 0) {
					System.out.println("SUCCESS");
					return;
				}
				System.out.println("FAILURE");
				return;
			}
		}

	}

}
0