結果

問題 No.197 手品
ユーザー masa
提出日時 2015-04-29 00:00:56
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 809 bytes
コンパイル時間 508 ms
コンパイル使用メモリ 55,640 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-27 07:24:49
合計ジャッジ時間 1,680 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 37 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 < 3; i++) {
		if (s1[i] == 'o') {
			n1++;
		}
		if (s2[i] == 'o') {
			n2++;
		}
	}

	if (n1 != n2) {
		cout << "SUCCESS" << endl;
		return 0;
	}

	int n_o = n1;
	if (n_o == 0 || n_o == 3) {
		cout << "FAILURE" << endl;
		return 0;
	}

	bool ret = false;
	if (n == 0) {
		if (s1 != s2) {
			ret = true;
		}
	} else if (n == 1) {
		char c = n_o == 1 ? 'o' : 'x';
		int idx1 = 0, idx2 = 0;
		for (int i = 0; i < 3; 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;
}
0