# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
201177 | SamAnd | Tavan (COCI16_tavan) | C++17 | 6 ms | 504 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int N = 505;
int n, m, k, x;
char a[N];
char b[N][33];
char ans[N];
int main()
{
scanf("%d%d%d%d", &n, &m, &k, &x);
scanf(" %s", a);
for (int i = 0; i < m; ++i)
scanf(" %s", b[i]);
for (int i = 0; i < m; ++i)
{
sort(b[i], b[i] + k);
long long xx = 1;
for (int j = i + 1; j < m; ++j)
{
xx *= k;
if (xx > x)
break;
}
long long y = xx;
for (int j = 0; j < k; ++j)
{
if (x <= y)
{
ans[i] = b[i][j];
x -= (y - xx);
break;
}
y += xx;
}
}
int j = 0;
for (int i = 0; i < n; ++i)
{
if (a[i] == '#')
a[i] = ans[j++];
}
printf("%s\n", a);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |