結果

問題 No.197 手品
ユーザー IL_mstaIL_msta
提出日時 2015-06-15 04:54:36
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,863 bytes
コンパイル時間 2,714 ms
コンパイル使用メモリ 78,168 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-27 09:33:41
合計ジャッジ時間 2,437 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,384 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 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 2 ms
4,376 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 1 ms
4,380 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 1 ms
4,380 KB
testcase_44 AC 1 ms
4,376 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:123:4: warning: ‘B’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    if(B==0){
    ^~
main.cpp:122:8: warning: ‘A’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   else if(A==2){
        ^~
main.cpp:87:3: warning: ‘aftT’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   if(befT == aftT){
   ^~
main.cpp:87:3: warning: ‘befT’ may be used uninitialized in this function [-Wmaybe-uninitialized]

ソースコード

diff #

#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>

#include <algorithm>
#include <cmath>

#include <string>
#include <list>
#include <queue>
#include <vector>
#include <complex>

/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) std::cout<<(p)<<std::endl;
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////

int main(void){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//
    //cout << setprecision(6);//
	
	string befS,aftS;
	int N;//[2 000 000 000]
	cin>>befS>>N>>aftS;
	int bef[3],aft[3];
	int befC=0,aftC=0;//oの数
	rep(i,3){
		if(befS[i]=='o'){
			bef[i] = 1;
			++befC;
		}else{
			bef[i] = 0;
		}
		if(aftS[i]=='o'){
			aft[i] = 1;
			++aftC;
		}else{
			aft[i] = 0;
		}
	}
	if( (befC == 0 && aftC==0) || (befC == 3 &&aftC==3)){
		P("FAILURE");
		return 0;
	}
	else if( befC != aftC){
		P("SUCCESS");
		return 0;
	}

	int befT,aftT;
	if(befC == 1){
		rep(i,3){
			if(befS[i] == 'o'){
				befT = i;
			}
		}
		rep(i,3){
			if(aftS[i] == 'o'){
				aftT = i;
			}
		}
	}
	else if(befC == 2){
		rep(i,3){
			if(befS[i] == 'x'){
				befT = i;
			}
		}
		rep(i,3){
			if(aftS[i] == 'x'){
				aftT = i;
			}
		}
	}
	//befT,aftT /0,1,2
	if(N==0){
		if(befT == aftT){
			P("FAILURE");
		}else{
			P("SUCCESS");
		}
	}
	else if(N==1){
		int A,B;
		if(befC == 1){
			rep(i,3){
				if(bef[i]==1)A=i;
				if(aft[i]==1)B=i;
			}
		}
		else if(befC == 2){
			rep(i,3){
				if(bef[i]==0)A=i;
				if(aft[i]==0)B=i;
			}
		}

		if(A==1){
			if(B==1){
				P("SUCCESS");
			}else{
				P("FAILURE");
			}
		}
		else if( A==0){
			if(B==2){
				P("SUCCESS");
			}else{
				P("FAILURE");
			}
		}
		else if(A==2){
			if(B==0){
				P("SUCCESS");
			}else{
				P("FAILURE");
			}
		}
	}
	else{
		P("FAILURE");
	}
	return 0;
}
0