結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
	int n,s;cin>>n>>s;
	int t=pow(3,n),u=0;
	for(int bit=0;bit<t;bit++){
		int ta=0,tb=0,tc=0,j=bit;
		for(int i=0;i<n;i++){
			if(j%3==0) ta++;
			else if(j%3==1) tb++;
			else tc++;
            j/=3;
		}if(ta==0||tb==0||tc==0) continue;
		u++;
		if(u<s) continue;
		string ans;
		j=bit;
		for(int i=0;i<n;i++){
			if(j%3==0) ans='A'+ans;
			else if(j%3==1) ans='B'+ans;
			else ans='C'+ans;
            j/=3;
		}cout<<ans<<"\n";
		return 0;
	}cout<<-1<<"\n";
	return 0;
}
0