結果
| 問題 | No.3299 K-th MMA String | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2025-10-09 08:52:52 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 10 ms / 2,000 ms | 
| コード長 | 585 bytes | 
| コンパイル時間 | 2,564 ms | 
| コンパイル使用メモリ | 198,868 KB | 
| 実行使用メモリ | 11,776 KB | 
| 最終ジャッジ日時 | 2025-10-09 08:53:06 | 
| 合計ジャッジ時間 | 5,148 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 20 | 
ソースコード
#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;
}
            
            
            
        