結果

問題 No.3135 AAABC
ユーザー daiota
提出日時 2025-05-02 22:57:51
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 69 ms / 2,000 ms
コード長 897 bytes
コンパイル時間 1,855 ms
コンパイル使用メモリ 169,100 KB
実行使用メモリ 20,680 KB
最終ジャッジ日時 2025-05-02 22:57:55
合計ジャッジ時間 3,285 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i=0;i<ll(n);i++)








int main(void){
	cin.tie(nullptr);  ios_base::sync_with_stdio(false);
	ll i,j;



	ll N,S;
	cin >> N >> S;

    queue<string> q;
     q.push("A");
     q.push("B");
     q.push("C");

      while(1){

    	  string s=q.front();

    	  if((ll)s.size()==N) break;

          q.pop();

          q.push(s+"A");
          q.push(s+"B");
          q.push(s+"C");

       }


      ll d=0;
      while(!q.empty()){

    	  string s=q.front();
    	  q.pop();

    	  ll a=0,b=0,c=0;
    	  REP(i,N){
    		  if(s[i]=='A') a++;
    		  if(s[i]=='B') b++;
    		  if(s[i]=='C') c++;
    	  }

    	  if(a!=0  && b!=0 && c!=0) d++;

    	  if(d==S){
    		  cout << s << endl;
    		  return 0;
    	  }


      }


      cout << -1 << endl;







	return 0;

}
0