結果

問題 No.197 手品
ユーザー nksk38nksk38
提出日時 2017-07-12 16:50:21
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,420 bytes
コンパイル時間 656 ms
コンパイル使用メモリ 75,344 KB
実行使用メモリ 5,260 KB
最終ジャッジ日時 2023-09-09 21:19:29
合計ジャッジ時間 2,158 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,384 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,388 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,384 KB
testcase_26 WA -
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 1 ms
4,384 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 WA -
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 1 ms
4,376 KB
testcase_39 AC 1 ms
4,380 KB
testcase_40 AC 2 ms
4,384 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 WA -
testcase_43 AC 1 ms
4,380 KB
testcase_44 AC 2 ms
4,380 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:60:25: warning: ‘s_ind_aft’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   int d = abs(s_ind_bef - s_ind_aft);
               ~~~~~~~~~~^~~~~~~~~~~
main.cpp:60:25: warning: ‘s_ind_bef’ may be used uninitialized in this function [-Wmaybe-uninitialized]

ソースコード

diff #

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, string> pls;

int main()
{
	string s_before, s_after;
	ll N,o_num_b=0,o_num_a= 0,x_num_a = 0,x_num_b = 0;
	string ans;

	cin >> s_before >> N >> s_after;

	for (int i = 0; i < s_before.size(); i++) {
		if (s_before[i] == 'o')o_num_b++;
		else x_num_b++;
	}

	for (int i = 0; i < s_after.size(); i++) {
		if (s_after[i] == 'o')o_num_a++;
		else x_num_a++;
	}

	if (s_before == "ooo" && s_after == "ooo") {
		ans = "SUCCESS";
	}
	else if ((o_num_b != o_num_a) || (x_num_a != x_num_b)) {
		ans = "SUCCESS";
	}
	else {
		char c;
		if (o_num_b < x_num_b)c = 'o';
		else c = 'x';

		int s_ind_bef;
		for (int i = 0; i < s_before.size(); i++) {
			if (s_before[i] == c)s_ind_bef = i;
		}

		int s_ind_aft;
		for (int i = 0; i < s_after.size(); i++) {
			if (s_after[i] == c)s_ind_aft = i;
		}

		int d = abs(s_ind_bef - s_ind_aft);
		if (N == 0) {
			if (s_before == s_after)ans = "FAILURE";
			else ans = "SUCCESS";
		}
		else if (N == 1) {
			if (d == 1 || d== 0)
				ans = "FAILURE";
			else
				ans = "SUCCESS";
		}
		else {
			ans = "FAILURE";
		}
	}
	cout << ans << endl;
	
	return	0;
}
0