結果
| 問題 | No.3135 AAABC |
| コンテスト | |
| ユーザー |
forest3
|
| 提出日時 | 2026-10-22 17:23:20 |
| 言語 | C++14 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 19 ms / 2,000 ms |
| + 960µs | |
| コード長 | 863 bytes |
| 記録 | |
| コンパイル時間 | 1,229 ms |
| コンパイル使用メモリ | 187,348 KB |
| 実行使用メモリ | 9,908 KB |
| 最終ジャッジ日時 | 2026-10-22 17:23:24 |
| 合計ジャッジ時間 | 4,117 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 32 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (ll i = a; i < b; i++)
using ll = long long;
int main(){
int n, s;
cin >> n >> s;
int d = 0;
vector<int> v;
while(1) {
vector<int> c(3);
int x = d;
int k = n;
while(x) {
int m = x % 3;
c[m]++;
x /= 3;
k--;
}
if(k < 0) break;
if((c[1] && c[2] && k > 0) || (c[0] && c[1] && c[2])) {
v.push_back(d);
}
d++;
}
int sz = v.size();
if(sz < s) {
cout << -1 << endl;
return 0;
}
int x = v[s - 1];
string t;
int k = n;
while(x) {
int m = x % 3;
t += char(m + 'A');
x /= 3;
k--;
}
rep(i, 0, k) t += 'A';
reverse(t.begin(), t.end());
cout << t << endl;
}
forest3