#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ar array
int n, m, k, x;
string s, cand[500];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m >> k >> x >> s, --x;
vector<int> d;
for (int i=0; i<m; ++i) {
cin >> cand[i];
sort(cand[i].begin(), cand[i].end());
d.push_back(x%k);
x/=k;
}
reverse(d.begin(), d.end());
int seen=0;
for (int i=0; i<n; ++i)
if (s[i]=='#')
s[i]=cand[seen][d[seen]], ++seen;
cout << s;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |