結果
| 問題 | 
                            No.197 手品
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2015-04-28 23:50:46 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 740 bytes | 
| コンパイル時間 | 418 ms | 
| コンパイル使用メモリ | 55,772 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-06-27 07:20:03 | 
| 合計ジャッジ時間 | 1,587 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 34 WA * 9 | 
ソースコード
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
int main() {
	long long n;
	string s1, s2;
	cin >> s1 >> n >> s2;
	int n1 = 0, n2 = 0;
	for (int i = 0; i <= 2; i++) {
		if (s1[i] == 'o') {
			n1++;
		}
		if (s2[i] == 'o') {
			n2++;
		}
	}
	if (n1 != n2) {
		cout << "SUCCESS" << endl;
		return 0;
	}
	bool ret = false;
	if (n == 0) {
		if (s1 != s2) {
			ret = true;
		}
	} else if (n == 1 && n1 > 0 && n2 > 0) {
		char c = n1 == 1 ? 'o' : 'x';
		int idx1 = 0, idx2 = 0;
		for (int i = 0; i < 2; i++) {
			if (s1[i] == c) {
				idx1 = i;
			}
			if (s2[i] == c) {
				idx2 = i;
			}
		}
		if (abs(idx1 - idx2) <= n) {
			ret = true;
		}
	}
	cout << (ret ? "SUCCESS" : "FAILURE") << endl;
	return 0;
}