結果

問題 No.197 手品
コンテスト
ユーザー hanorver
提出日時 2015-10-29 15:55:03
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,175 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 448 ms
コンパイル使用メモリ 92,116 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2026-03-15 10:23:52
合計ジャッジ時間 1,547 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 41 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>

int main() {
	std::string start, end;
	long long n;

	std::cin >> start >> n >> end;

	int scoin = std::count(start.begin(), start.end(), 'o'), // 最初のコインの枚数
		ecoin = std::count(end.begin(), end.end(), 'o'); // 最後のコインの枚数

	// コインの数が最初と最後で違う
	if (scoin != ecoin) {
		std::cout << "SUCCESS" << std::endl;
		return 0;
	}

	/******************************************
	 以下は最初と最後のコインの枚数が同じ
	*******************************************/

	// コインの枚数が3枚か0枚ならばどうやってもあり得る状態になる
	if (scoin == 3 || scoin == 0) {
		std::cout << "FAILURE" << std::endl;
		return 0;
	}

	int s = -1, e = -1;
	if (start[0] != end[0])s = 0;
	if (start[1] != end[1]) {
		if (s != -1)e = 1;
		else s = 1;
	}
	if (start[2] != end[2])e = 2;
	if (s != -1) n -= e - s;
	if (n < 0) {
		std::cout << "SUCCESS" << std::endl;
		return 0;
	}


	if (end[0] == end[1] || end[1] == end[2] || n >= 0) std::cout << "FAILURE" << std::endl;
	else std::cout << "SUCCESS" << std::endl;

	return 0;

}
0