結果

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

ソースコード

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 < s1.size(); 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;
	}

	if (n1 == 1 && s1 == "oxo" && s1 == s2) {
		cout << "SUCCESS" << endl;
		return 0;
	}

	char c = n_o == 1 ? 'o' : 'x';
	int idx1 = 0, idx2 = 0;
	for (int i = 0; i < s1.size(); i++) {
		if (s1[i] == c) {
			idx1 = i;
		}
		if (s2[i] == c) {
			idx2 = i;
		}
	}

	if ((long long)abs(idx1 - idx2) > n) {
		cout << "SUCCESS" << endl;
	} else {
		cout << "FAILURE" << endl;
	}
	return 0;
}
0