結果

問題 No.197 手品
ユーザー どらら
提出日時 2016-05-04 14:44:53
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 975 bytes
コンパイル時間 746 ms
コンパイル使用メモリ 89,108 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-27 13:29:24
合計ジャッジ時間 1,885 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 41 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;

map<string,int> memo;

void solve(string s, int cnt, int N){
  if(cnt > N) return;
  if(memo.count(s) > 0) return;
  memo[s] = 1;
  
  swap(s[0], s[1]);
  solve(s, cnt+1, N);
  swap(s[0], s[1]);
  swap(s[1], s[2]);
  solve(s, cnt+1, N);
  swap(s[1], s[2]);
}

int main(){
  string SB, SA;
  int N;
  cin >> SB;
  cin >> N;
  cin >> SA;

  solve(SB, 0, N);


  
  if(memo.count(SA) > 0) cout << "FAILURE" << endl;
  else cout << "SUCCESS" << endl;
  
  return 0;
}
0