結果

問題 No.2766 Delicious Multiply Spice
コンテスト
ユーザー ripity
提出日時 2024-05-27 16:23:28
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 474 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,167 ms
コンパイル使用メモリ 216,180 KB
実行使用メモリ 11,972 KB
最終ジャッジ日時 2026-07-04 19:20:42
合計ジャッジ時間 9,494 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 8
other AC * 23 TLE * 1 -- * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

long long N;
vector<string> ans_all;

mt19937 ra(time(NULL));

void dfs(long long x, string S) {
  if(x == N) {
    ans_all.push_back(S);
  }else if(x < N) {
    if(ra() & 1) {
      dfs(2 * x + 1, S + 'A');
      dfs(3 * x + 1, S + 'B');
    }else {
      dfs(3 * x + 1, S + 'B');
      dfs(2 * x + 1, S + 'A');
    }
  }
}

int main() {
  cin >> N;
  dfs(1, "");
  assert(ans_all.size() == 1);
  cout << ans_all[0] << endl;
}
0