#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
ll n,m,k,x;
cin>>n>>m>>k>>x;
string s;
cin>>s;
ll num=0;
char ans[m];
char c[m][k];
for(ll i=0;i<m;i++)
{
for(ll j=0;j<k;j++)
cin>>c[i][j];
}
x--;
for(ll i=0;i<m;i++)
{
sort(c[i],c[i]+k);
ans[i]=c[i][0];
}
for(ll i=m-1;i>=0;i--)
{
ans[i]=c[i][x%k];
x=x/k;
}
for(ll i=0;i<n;i++)
{
if(s[i]=='#')
{
s[i]=ans[num];
num++;
}
}
cout<<s;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
432 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |