結果
| 問題 | 
                            No.197 手品
                             | 
                    
| コンテスト | |
| ユーザー | 
                             spacia
                         | 
                    
| 提出日時 | 2016-01-04 21:58:17 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,088 bytes | 
| コンパイル時間 | 2,182 ms | 
| コンパイル使用メモリ | 77,292 KB | 
| 実行使用メモリ | 50,500 KB | 
| 最終ジャッジ日時 | 2024-06-27 13:14:12 | 
| 合計ジャッジ時間 | 6,052 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 35 WA * 8 | 
ソースコード
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 % 2 != 0;
			} else {
				return n == 0;
			}
		} else {
			if (p2 == 1) {
				return n % 2 == 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");
		
	}
}
            
            
            
        
            
spacia