結果

問題 No.197 手品
コンテスト
ユーザー alpha_virginis
提出日時 2015-04-29 16:18:29
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 802 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,440 ms
コンパイル使用メモリ 180,316 KB
実行使用メモリ 186,932 KB
最終ジャッジ日時 2026-04-02 20:13:48
合計ジャッジ時間 1,796 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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