結果
| 問題 |
No.197 手品
|
| コンテスト | |
| ユーザー |
smiken_61
|
| 提出日時 | 2015-10-23 17:40:15 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,107 bytes |
| コンパイル時間 | 488 ms |
| コンパイル使用メモリ | 63,072 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-27 13:08:51 |
| 合計ジャッジ時間 | 1,703 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 41 WA * 2 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:90:1: warning: ‘ans’ may be used uninitialized [-Wmaybe-uninitialized]
90 | if(ans==0) cout<<"FAILURE"<<endl;
| ^~
ソースコード
#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=-1,n=-1;
//cout<<k<<" "<<l<<endl;
if(k!=l) ans=1;
else if(k==0 || k==3) ans=0;
else if(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;
}
smiken_61