結果
問題 | No.3135 AAABC |
ユーザー |
|
提出日時 | 2025-05-02 21:43:08 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 2,000 ms |
コード長 | 709 bytes |
コンパイル時間 | 1,827 ms |
コンパイル使用メモリ | 193,852 KB |
実行使用メモリ | 6,272 KB |
最終ジャッジ日時 | 2025-05-02 21:43:11 |
合計ジャッジ時間 | 2,770 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 32 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int a = 0,b = 0,c = 0,N,S; cin >> N >> S; string now = "",answer = ""; auto dfs = [&](auto dfs) -> void { if(now.size() == N){ if(min({a,b,c}) > 0){ S--; if(S == 0) answer = now; } return; } now += 'A'; a++; dfs(dfs); now.pop_back(); a--; now += 'B'; b++; dfs(dfs); now.pop_back(); b--; now += 'C'; c++; dfs(dfs); now.pop_back(); c--; }; dfs(dfs); if(answer == "") answer = "-1"; cout << answer << endl; }