結果

問題 No.197 手品
ユーザー どらら
提出日時 2016-05-04 15:09:07
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,414 bytes
コンパイル時間 848 ms
コンパイル使用メモリ 90,604 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-20 03:47:49
合計ジャッジ時間 2,164 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

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;

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

  map<string,int> memo;
  string str(3,'x');
  
  if(N == 0){
    memo[SB] = 1;
  }
  else if(N == 1){
    str[0] = SB[1];
    str[1] = SB[0];
    str[2] = SB[2];
    memo[str] = 1;
    str[0] = SB[0];
    str[1] = SB[2];
    str[2] = SB[1];
    memo[str] = 1;
  }
  else if(N%2==0){
    memo[SB] = 1;

    str[0] = SB[2];
    str[1] = SB[0];
    str[2] = SB[1];
    memo[str] = 1;

    str[0] = SB[1];
    str[1] = SB[2];
    str[2] = SB[0];
    memo[str] = 1;
  }
  else {
    str[0] = SB[0];
    str[1] = SB[2];
    str[2] = SB[1];
    memo[str] = 1;

    str[0] = SB[1];
    str[1] = SB[0];
    str[2] = SB[2];
    memo[str] = 1;
    
    str[0] = SB[2];
    str[1] = SB[1];
    str[2] = SB[0];
    memo[str] = 1;
  }

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