結果

問題 No.197 手品
ユーザー smiken_61smiken_61
提出日時 2015-10-23 17:33:04
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,085 bytes
コンパイル時間 472 ms
コンパイル使用メモリ 63,568 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-27 13:08:38
合計ジャッジ時間 1,687 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 41 WA * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:18: warning: ‘n’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    9 | if(a>b) return a-b;
      |                  ^
main.cpp:37:11: note: ‘n’ was declared here
   37 | int ans,m,n;
      |           ^
main.cpp:9:18: warning: ‘m’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    9 | if(a>b) return a-b;
      |                  ^
main.cpp:37:9: note: ‘m’ was declared here
   37 | int ans,m,n;
      |         ^

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <queue>
using namespace std;

int abs1(int a,int b){
if(a>b) return a-b;
else return b-a;

}


int main(){
string s,t;
int k=0,l=0,kai;
int a[3],b[3];
cin>>s;
for(int i=0;i<3;i++){
	if(s[i]=='o'){
		a[i]=0;
		k=k+1;	
	}
	else a[i]=1;
}
cin>>kai;
cin>>t;

for(int i=0;i<3;i++){
	if(t[i]=='o'){
		b[i]=0;
		l=l+1;	
	}
	else b[i]=1;
}
int ans,m,n;
//cout<<k<<" "<<l<<endl;
if(k!=l) ans=1;
else if(k==0 || k==3 ||s==t) ans=0;
else if(k==1){
	for(int i=0;i<3;i++){
		if(a[i]==0) m=i;
		if(b[i]==0) n=i;	
	}
//cout<<m<<" "<<n<<endl;
	if(m==n){
		ans=0;
	}
	else if(abs1(m,n)==1){
		if(kai>=1) ans=0;
		else ans=1;
	}
	else{
		if(kai>=2) ans=0;
		else ans=1;
	}



}
else if(k==2){
	for(int i=0;i<3;i++){
		if(a[i]==1) m=i;
		if(b[i]==1) n=i;	
	}
//cout<<m<<" "<<n<<endl;
	if(m==n){
		ans=0;
	}
	else if(abs1(m,n)==1){
		if(kai>=1) ans=0;
		else ans=1;
	}
	else{
		if(kai>=2) ans=0;
		else ans=1;
	}



}


//cout<<ans<<endl;



if(ans==0) cout<<"FAILURE"<<endl;
else cout<<"SUCCESS"<<endl;


return 0;
}
0