結果
| 問題 | 
                            No.197 手品
                             | 
                    
| コンテスト | |
| ユーザー | 
                             sntea
                         | 
                    
| 提出日時 | 2015-10-29 14:40:02 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,296 bytes | 
| コンパイル時間 | 716 ms | 
| コンパイル使用メモリ | 84,516 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-06-27 13:09:15 | 
| 合計ジャッジ時間 | 1,846 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 41 WA * 2 | 
ソースコード
#include <iostream>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <utility>
#include <cstdio>
#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef pair<int,int> P;
typedef long long int LL;
typedef pair<LL,LL> LP;
int N;
string sb,sa;
bool dfs(int k,string s);
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>sa>>N>>sb;
	if(N>10){
		int nax=0;
		int nbx=0;
		REP(i,3){
			if(sa[i]=='x')	nax++;
			if(sb[i]=='x')	nbx++;
		}
		if(nax==nbx){
			cout<<"FAILURE"<<endl;
		}else{
			cout<<"SUCCESS"<<endl;
		}
	}else{
		if(dfs(0,sb)){
			cout<<"FAILURE"<<endl;
		}else{
			cout<<"SUCCESS"<<endl;
		}
	}
	return 0;
}
bool dfs(int k,string s)
{
	if(s==sa)	return true;
	if(k==N){
		return false;
	}else{
		string s1=s.substr(0,1)+s.substr(2,1)+s.substr(1,1);
		string s2=s.substr(1,1)+s.substr(0,1)+s.substr(2,1);
		return dfs(k+1,s1)||dfs(k+1,s2);
	}
}
            
            
            
        
            
sntea