#include<bits/stdc++.h>
using namespace std;
string pretvori(int num, int base){
string t;
while(num){
t += (num % base) + '0';
num /= base;
}
return t;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n,m,k,x;
cin >> n >> m >> k >> x;
string s;
cin >> s;
vector <string> v(m);
for(int i = 0; i < m; i++){
cin >> v[i];
sort(v[i].begin(), v[i].end());
}
string rj = pretvori(x - 1, k);
int lj = 0;
for(auto x : s) if(x == '#') lj++;
while(rj.size() != lj) rj.push_back('0');
reverse(rj.begin(), rj.end());
int ind = 0;
for(auto x : rj){
s[s.find('#')] = v[ind++][x - '0'];
}
cout << s;
}
Compilation message
tavan.cpp: In function 'int main()':
tavan.cpp:31:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(rj.size() != lj) rj.push_back('0');
~~~~~~~~~~^~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
508 KB |
Output is correct |
3 |
Correct |
2 ms |
524 KB |
Output is correct |
4 |
Correct |
2 ms |
524 KB |
Output is correct |
5 |
Correct |
2 ms |
524 KB |
Output is correct |
6 |
Correct |
2 ms |
528 KB |
Output is correct |
7 |
Correct |
2 ms |
704 KB |
Output is correct |
8 |
Correct |
2 ms |
704 KB |
Output is correct |
9 |
Correct |
2 ms |
704 KB |
Output is correct |
10 |
Correct |
2 ms |
704 KB |
Output is correct |