# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
201177 | 2020-02-09T15:24:44 Z | SamAnd | Tavan (COCI16_tavan) | C++17 | 6 ms | 504 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 5 ms | 376 KB | Output is correct |
4 | Correct | 5 ms | 376 KB | Output is correct |
5 | Correct | 6 ms | 504 KB | Output is correct |
6 | Correct | 5 ms | 376 KB | Output is correct |
7 | Correct | 5 ms | 256 KB | Output is correct |
8 | Correct | 5 ms | 376 KB | Output is correct |
9 | Correct | 5 ms | 376 KB | Output is correct |
10 | Correct | 5 ms | 256 KB | Output is correct |