結果

問題 No.3299 K-th MMA String
コンテスト
ユーザー GOTKAKO
提出日時 2025-10-09 08:52:52
言語 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
結果
AC  
実行時間 5 ms / 2,000 ms
+ 656µs
コード長 585 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,226 ms
コンパイル使用メモリ 214,588 KB
実行使用メモリ 10,368 KB
最終ジャッジ日時 2026-07-15 15:50:11
合計ジャッジ時間 3,003 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int N,K; cin >> N >> K;
    bool end = false;
    string answer = "";
    auto dfs = [&](auto dfs,int pos,bool ok,int last) -> void {
        if(last == 6) ok = true;
        if(pos == N){K -= ok; return;}
        dfs(dfs,pos+1,ok,last*2%8);
        if(K == 0){answer += 'A'; return;}
        dfs(dfs,pos+1,ok,last*2%8+1);
        if(K == 0) answer += 'M';

    };
    dfs(dfs,0,false,0);
    reverse(answer.begin(),answer.end());
    cout << answer << endl;
}
0