結果
| 問題 |
No.197 手品
|
| コンテスト | |
| ユーザー |
ty70
|
| 提出日時 | 2015-05-29 00:01:23 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,962 bytes |
| コンパイル時間 | 718 ms |
| コンパイル使用メモリ | 90,932 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-27 09:46:28 |
| 合計ジャッジ時間 | 1,941 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 42 WA * 1 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm> // require sort next_permutation count __gcd reverse etc.
#include <cstdlib> // require abs exit atof atoi
#include <cstdio> // require scanf printf
#include <functional>
#include <numeric> // require accumulate
#include <cmath> // require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip> // require setw
#include <sstream> // require stringstream
#include <cstring> // require memset
#include <cctype> // require tolower, toupper
#include <fstream> // require freopen
#include <ctime> // require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define SUCCESS 0
#define FAILURE 1
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const string pos[4][3] = { { "xxx", "xxx", "xxx" },
{ "xxo", "xox", "oxx" },
{ "xoo", "oxo", "oox" },
{ "ooo", "ooo", "ooo" } };
const string res[2] = { "SUCCESS", "FAILURE" };
int main()
{
ios_base::sync_with_stdio(0);
// int T; cin >> T;
// while (T-- ){
string s_before; cin >> s_before;
int N; cin >> N;
string s_after; cin >> s_after;
int nb = (int)count (ALL (s_before ), 'o' );
int na = (int)count (ALL (s_after ), 'o' );
int ans = -1;
if (nb != na ){
ans = SUCCESS;
}else{
int ind_before = -1;
int ind_after = -1;
rep (i, 3 ) if (pos[nb][i] == s_before ) ind_before = i;
rep (i, 3 ) if (pos[na][i] == s_after ) ind_after = i;
if (na == 0 || na == 3 ){
ans = FAILURE;
}else
if (na == 1 ){
// xxo -> xxo xox -> xox oxx -> oxx
if (ind_before == ind_after ){
if (ind_before == 0 || ind_before == 2 ){
ans = FAILURE;
}else{ // if (ind_before == 1 ) xox
if (N == 1 )
ans = SUCCESS;
else
ans = FAILURE;
} // end if
}else{
// xxo -> oxx oxx -> xxo
if (abs (ind_before - ind_after ) == 2 ){
if (N <= 1 )
ans = SUCCESS;
else
ans = FAILURE;
// xxo -> xox xox -> oxx
}else{ // if (abs(ind_before - ind_after ) == 1 )
ans = FAILURE;
} // end if
} // end if
}else{
// xoo -> xoo oxo -> oxo oox -> oox
if (ind_before == ind_after ){
if (ind_before == 0 || ind_before == 2 ){
ans = FAILURE;
}else{ // if (ind_before == 1 ) oxo
if (N == 1 )
ans = SUCCESS;
else
ans = FAILURE;
} // end if
}else{
// xoo -> oox oox -> xoo
if (abs (ind_before - ind_after ) == 2 ){
if (N <= 1 )
ans = SUCCESS;
else
ans = FAILURE;
// xoo -> oxo oxo -> oox
}else{ // if (abs(ind_before - ind_after ) == 1 )
ans = FAILURE;
} // end if
} // end if
} // end if
} // end if
// cerr << s_before << ' ' << N << ' ' << s_after << endl;
cout << res[ans] << endl;
// } // end while
return 0;
}
ty70