結果
| 問題 |
No.3299 K-th MMA String
|
| コンテスト | |
| ユーザー |
startcpp
|
| 提出日時 | 2025-10-05 14:01:55 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 2,000 ms |
| コード長 | 991 bytes |
| コンパイル時間 | 786 ms |
| コンパイル使用メモリ | 78,064 KB |
| 実行使用メモリ | 9,088 KB |
| 最終ジャッジ日時 | 2025-10-05 14:01:57 |
| 合計ジャッジ時間 | 1,544 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cassert>
#include <atcoder/modint>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;
using namespace atcoder;
int n, K;
int cnt = 0;
string ans;
bool dfs(string &s, bool flag) {
if (s.length() == n) {
if (flag) {
cnt++;
if (cnt == K) {
ans = s;
return true;
}
}
return false;
}
s.push_back('A');
bool res = dfs(s, flag || (s.length() >= 3 && s[s.length() - 3] == 'M' && s[s.length() - 2] == 'M'));
s.pop_back();
if (res) return true;
s.push_back('M');
res = dfs(s, flag);
s.pop_back();
return res;
}
signed main() {
cin >> n >> K;
string s;
dfs(s, false);
cout << ans << endl;
return 0;
}
startcpp