結果
問題 |
No.3299 K-th MMA String
|
ユーザー |
![]() |
提出日時 | 2025-10-08 07:40:24 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,081 ms / 2,000 ms |
コード長 | 758 bytes |
コンパイル時間 | 4,031 ms |
コンパイル使用メモリ | 289,460 KB |
実行使用メモリ | 67,168 KB |
最終ジャッジ日時 | 2025-10-08 07:40:43 |
合計ジャッジ時間 | 16,827 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; bool chmin(auto &a, auto b) { return a > b ? a = b, true : false; } bool chmax(auto &a, auto b) { return a < b ? a = b, true : false; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, K; cin >> N >> K; K--; int M = min(N, 20); vector<string> S; for (int i = 0; i < 1 << M; i++) { string T; for (int j = 0; j < M; j++) { T.push_back("AM"[i >> j & 1]); } bool fn = false; for (int j = 0; j + 3 <= M; j++) { if (T.substr(j, 3) == "MMA") fn = true; } if (fn) S.push_back(T); } sort(S.begin(), S.end()); cout << string(N - M, 'A') + S[K] << endl; }