結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
56,000 KB
testcase_01 AC 117 ms
55,752 KB
testcase_02 AC 116 ms
56,052 KB
testcase_03 AC 118 ms
55,448 KB
testcase_04 AC 118 ms
56,328 KB
testcase_05 AC 118 ms
56,120 KB
testcase_06 AC 118 ms
56,044 KB
testcase_07 AC 119 ms
55,400 KB
testcase_08 AC 118 ms
55,812 KB
testcase_09 AC 117 ms
55,680 KB
testcase_10 AC 118 ms
56,116 KB
testcase_11 AC 118 ms
56,220 KB
testcase_12 WA -
testcase_13 AC 119 ms
56,228 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 119 ms
55,820 KB
testcase_24 AC 120 ms
55,832 KB
testcase_25 AC 120 ms
55,732 KB
testcase_26 AC 117 ms
55,456 KB
testcase_27 WA -
testcase_28 AC 120 ms
55,336 KB
testcase_29 WA -
testcase_30 AC 127 ms
55,968 KB
testcase_31 AC 119 ms
55,636 KB
testcase_32 AC 120 ms
55,796 KB
testcase_33 WA -
testcase_34 AC 119 ms
55,768 KB
testcase_35 AC 120 ms
55,816 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 121 ms
55,720 KB
testcase_39 WA -
testcase_40 AC 122 ms
56,280 KB
testcase_41 WA -
testcase_42 AC 119 ms
55,572 KB
testcase_43 AC 122 ms
55,456 KB
testcase_44 WA -
testcase_45 AC 126 ms
55,424 KB
testcase_46 WA -
権限があれば一括ダウンロードができます

ソースコード

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;
			}
			System.out.println("SUCCESS");
			return;
		}

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

	}

}
0