提出 #22808820
ソースコード 拡げる
// {{{
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using vi = vector<int>;
using pii = pair<int, int>;
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
#define debug(x...)
#define debug_arr(x...)
#ifdef LOCAL
#include "prettyprint.hpp"
#endif
// }}}
const int N = 66;
LL c[N][N];
LL a, b, k;
int main()
{
#ifdef LOCAL
freopen("in", "r", stdin);
// freopen("out", "w", stdout);
#endif
ios::sync_with_stdio(false);
cin.tie(0);
int lim = 60;
c[0][0] = 1;
for (int i = 1; i <= lim; ++i)
{
c[i][0] = c[i][i] = 1;
for (int j = 1; j < i; ++j)
{
c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
}
}
while (cin >> a >> b >> k)
{
LL left = k;
string ans = "";
int ca = a, cb = b;
for (int i = 1; i <= a + b; i++)
{
if (ca == 0)
{
ans += "b";
cb--;
}
else if (cb == 0)
{
ans += "a";
ca--;
}
else
{
LL cnt = c[ca + cb - 1][ca - 1];
debug(ca, cb, cnt);
if (cnt >= k)
{
ans += "a";
ca--;
}
else
{
ans += "b";
cb--;
k -= cnt;
}
}
}
cout << ans << endl;
}
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | D - aab aba baa |
| ユーザ | mickeyandkaka |
| 言語 | C++ (GCC 9.2.1) |
| 得点 | 400 |
| コード長 | 1673 Byte |
| 結果 | AC |
| 実行時間 | 7 ms |
| メモリ | 3692 KiB |
コンパイルエラー
./Main.cpp: In function ‘int main()’:
./Main.cpp:43:12: warning: unused variable ‘left’ [-Wunused-variable]
43 | LL left = k;
| ^~~~
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 400 / 400 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | sample_00, sample_01 |
| All | big_00, big_01, big_02, big_03, big_04, bound_00, bound_01, bound_02, bound_03, sample_00, sample_01, small_00, small_01, test_00, test_01, test_02, test_03, test_04, test_05, test_06, test_07, test_08, test_09, test_10, test_11, test_12, test_13, test_14 |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| big_00 | AC | 7 ms | 3676 KiB |
| big_01 | AC | 2 ms | 3648 KiB |
| big_02 | AC | 2 ms | 3492 KiB |
| big_03 | AC | 2 ms | 3492 KiB |
| big_04 | AC | 2 ms | 3600 KiB |
| bound_00 | AC | 2 ms | 3552 KiB |
| bound_01 | AC | 3 ms | 3604 KiB |
| bound_02 | AC | 2 ms | 3608 KiB |
| bound_03 | AC | 2 ms | 3644 KiB |
| sample_00 | AC | 2 ms | 3648 KiB |
| sample_01 | AC | 2 ms | 3604 KiB |
| small_00 | AC | 2 ms | 3604 KiB |
| small_01 | AC | 2 ms | 3588 KiB |
| test_00 | AC | 2 ms | 3688 KiB |
| test_01 | AC | 2 ms | 3600 KiB |
| test_02 | AC | 2 ms | 3540 KiB |
| test_03 | AC | 2 ms | 3656 KiB |
| test_04 | AC | 2 ms | 3640 KiB |
| test_05 | AC | 2 ms | 3648 KiB |
| test_06 | AC | 2 ms | 3548 KiB |
| test_07 | AC | 2 ms | 3548 KiB |
| test_08 | AC | 2 ms | 3576 KiB |
| test_09 | AC | 2 ms | 3620 KiB |
| test_10 | AC | 2 ms | 3600 KiB |
| test_11 | AC | 2 ms | 3680 KiB |
| test_12 | AC | 2 ms | 3644 KiB |
| test_13 | AC | 2 ms | 3604 KiB |
| test_14 | AC | 2 ms | 3692 KiB |