結果
| 問題 | No.3299 K-th MMA String | 
| コンテスト | |
| ユーザー |  ripity | 
| 提出日時 | 2025-10-05 14:36:25 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 12 ms / 2,000 ms | 
| コード長 | 865 bytes | 
| コンパイル時間 | 4,993 ms | 
| コンパイル使用メモリ | 335,020 KB | 
| 実行使用メモリ | 14,464 KB | 
| 最終ジャッジ日時 | 2025-10-05 14:36:36 | 
| 合計ジャッジ時間 | 5,983 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 20 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
using mint = modint998244353;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, K;
    cin >> N >> K;
    int cnt = 0;
    string ans = "";
    auto dfs = [&](auto dfs, int p = 0, int prv = 0, bool f = false) -> bool {
        // cout << p << " " << prv << f << " " << endl;
        if(prv == 6) f = true;
        if(p == N) {
            cnt += f;
            return (cnt == K);
        }else {
            for(int c : {0, 1}) {
                if(dfs(dfs, p + 1, ((prv << 1) | c) & 7, f)) {
                    ans += "AM"[c];
                    return true;
                }
            }
            return false;
        }
    };
    dfs(dfs);
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}
            
            
            
        