結果

問題 No.197 手品
ユーザー spaciaspacia
提出日時 2016-01-04 22:13:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 45 ms / 1,000 ms
コード長 1,080 bytes
コンパイル時間 2,107 ms
コンパイル使用メモリ 74,320 KB
実行使用メモリ 49,708 KB
最終ジャッジ日時 2023-09-27 09:37:26
合計ジャッジ時間 5,787 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,284 KB
testcase_01 AC 42 ms
47,764 KB
testcase_02 AC 42 ms
49,636 KB
testcase_03 AC 43 ms
49,260 KB
testcase_04 AC 43 ms
49,596 KB
testcase_05 AC 44 ms
49,268 KB
testcase_06 AC 43 ms
49,708 KB
testcase_07 AC 43 ms
49,424 KB
testcase_08 AC 43 ms
49,220 KB
testcase_09 AC 44 ms
49,336 KB
testcase_10 AC 42 ms
49,332 KB
testcase_11 AC 43 ms
49,252 KB
testcase_12 AC 44 ms
49,648 KB
testcase_13 AC 43 ms
49,304 KB
testcase_14 AC 43 ms
49,148 KB
testcase_15 AC 43 ms
49,212 KB
testcase_16 AC 44 ms
49,296 KB
testcase_17 AC 43 ms
49,344 KB
testcase_18 AC 44 ms
49,156 KB
testcase_19 AC 43 ms
49,336 KB
testcase_20 AC 45 ms
47,608 KB
testcase_21 AC 43 ms
49,328 KB
testcase_22 AC 44 ms
49,324 KB
testcase_23 AC 43 ms
49,356 KB
testcase_24 AC 43 ms
49,156 KB
testcase_25 AC 43 ms
49,224 KB
testcase_26 AC 43 ms
49,456 KB
testcase_27 AC 43 ms
49,224 KB
testcase_28 AC 43 ms
49,264 KB
testcase_29 AC 43 ms
49,252 KB
testcase_30 AC 42 ms
49,392 KB
testcase_31 AC 42 ms
49,352 KB
testcase_32 AC 43 ms
49,132 KB
testcase_33 AC 44 ms
49,268 KB
testcase_34 AC 44 ms
49,220 KB
testcase_35 AC 44 ms
49,252 KB
testcase_36 AC 44 ms
49,448 KB
testcase_37 AC 44 ms
49,324 KB
testcase_38 AC 44 ms
49,144 KB
testcase_39 AC 43 ms
49,148 KB
testcase_40 AC 44 ms
49,264 KB
testcase_41 AC 44 ms
49,268 KB
testcase_42 AC 43 ms
49,308 KB
testcase_43 AC 45 ms
49,324 KB
testcase_44 AC 43 ms
49,220 KB
testcase_45 AC 43 ms
49,264 KB
testcase_46 AC 44 ms
49,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.math.*;

class Main {
	
	public static void out (Object o) {
		System.out.println(o);
	}
	
	public static boolean solve (String s , String t , int n) {
		int cnt1 = 0 , cnt2 = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == 'o') cnt1++;
			if (t.charAt(i) == 'o') cnt2++;
		}
		if (cnt1 != cnt2) return true;
		if (cnt1 == 0 || cnt1 == 3) return false;
		int p1 = -1 , p2 = -1;
		if (cnt1 == 1) {
			p1 = s.indexOf("o");
			p2 = t.indexOf("o");
		} else {
			p1 = s.indexOf("x");
			p2 = t.indexOf("x");
		}
		if (p1 == 1) {
			if (p2 == 1) {
				return n == 1;
			} else {
				return n == 0;
			}
		} else {
			if (p2 == 1) {
				return n == 0;
			} else {
				return p1 == p2 ? false : n < 2;
			}
		}
	}
	
	public static void main (String[] args) throws IOException {
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		String s = br.readLine();
		int n = Integer.parseInt(br.readLine());
		String t = br.readLine();
		
		out(solve(s , t , n) ? "SUCCESS" : "FAILURE");
		
	}
}
0