結果
問題 | No.3135 AAABC |
ユーザー |
|
提出日時 | 2025-05-02 22:58:53 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 18 ms / 2,000 ms |
コード長 | 1,640 bytes |
コンパイル時間 | 2,013 ms |
コンパイル使用メモリ | 194,536 KB |
実行使用メモリ | 6,272 KB |
最終ジャッジ日時 | 2025-05-02 22:58:56 |
合計ジャッジ時間 | 2,898 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 32 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #define mod99 998244353 #define mod107 1000000007 #define endl "\n" #define rep(i,n) for (int i = 0; (i) < (n); ++i) #define prep(i,a,n) for (int i = (a); i < (n); ++i) #define rrep(i,n) for (int i = n-1; i >= 0; --i) #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(), a.rend() #define si(x) ((int)(x).size()) //#define YN(bool) if(bool){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;} #define yn(bool) if(bool){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;} #define PRE(x) cout << fixed << setprecision(x) #define YES cout << "Yes\n" #define NO cout << "No\n" template <typename T> inline T gcd(T a,T b) {return (b==0)?a:gcd(b,a%b);} template <typename T> inline T lcm(T a, T b) {return a/gcd(a,b)*b;} template<class T>bool chmax(T &a, T b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, T b) { if (b<a) { a=b; return 1; } return 0; } int dx[4]={1,0,-1,0};int dy[4]={0,1,0,-1};using ull = unsigned long long; string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; //string abc = "abcdefghijklmnopqrstuvwxyz"; bool issubsquence(string s,string t){ ll i=0; for(char c:t){ if(i<si(s)&&s[i]==c) i++; } return i==si(s); } int n; ll s, memo = 0; string ans = "-1"; void dfs(string S, bool A, bool B, bool C) { if(si(S)==n) { if(A&&B&&C) { memo++; if(memo == s) ans = S; } return; } if(ans !="-1") return; dfs(S+'A',true,B,C); dfs(S+'B',A,true,C); dfs(S+'C',A,B,true); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> s; dfs("",false,false,false); cout << ans << endl; }