#include <bits/stdc++.h>
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
const int N = 501;
int n, m, k, x;
string s, t[N];
ll pr;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif // LOCAL
cin >> n >> m >> k >> x >> s;
for (int i = 0; i < m; i++) {
cin >> t[i];
sort(all(t[i]));
}
pr = 1;
for (int i = m - 1; i > 0; i--) pr *= t[i].size();
vector <int> ans;
for (int i = 0; i < m; i++){
for (int j = 0; j < t[i].size(); j++){
if (x - pr * j < 1){
ans.push_back(j - 1);
x -= pr * j;
break;
}
}
if (ans.size() == i) {
ans.push_back(t[i].size() - 1);
x -= pr * (t[i].size() - 1);
}
if (i + 1 < m)
pr /= t[i + 1].size();
}
reverse(all(ans));
// for (auto u: ans) cout << u << " ";
int ind = 0;
for (int i = 0; i < n; i++){
if (s[i] != '#') {
cout << s[i];
continue;
}
cout << t[ind++][ans.back()];
ans.pop_back();
}
}
Compilation message
tavan.cpp: In function 'int main()':
tavan.cpp:30:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = 0; j < t[i].size(); j++){
~~^~~~~~~~~~~~~
tavan.cpp:37:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (ans.size() == i) {
~~~~~~~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
8 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
9 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
10 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |