結果

問題 No.197 手品
ユーザー alpha_virginis
提出日時 2015-04-29 16:18:29
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 802 bytes
コンパイル時間 1,382 ms
コンパイル使用メモリ 160,804 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-20 03:36:40
合計ジャッジ時間 2,279 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

int main() {

  std::string str_i, str_o;
  std::string str;
  long N;
  long p[12];
  bool ans = true;
  
  p[0] = 1;
  for(int i = 1; i < 12; ++i) {
    p[i] = 2 * p[i-1];
  }

  std::cin >> str_i >> N >> str_o;

  if( N >= 12 ) {
    N = 6 + (N % 6);
  }

  if( N == 0 ) {
    if( str_i == str_o ) {
      ans = false;
      goto label_1;
    }
  }

  for(int i = 0; i < p[N]; ++i) {
    str = str_i;
    for(int j = 0; j < N; ++j) {
      if( (i & (1 << j)) == 0 ) {
	std::swap(str[0], str[1]);
      }
      else {
	std::swap(str[1], str[2]);
      }
    }
    if( str == str_o ) {
      ans = false;
      goto label_1;
    }
  }

 label_1:
  if( ans ) {
    std::cout << "SUCCESS" << std::endl;
  }
  else {
    std::cout << "FAILURE" << std::endl;
  }


  return 0;
}
0