#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pob pop_back
using namespace std;
int n,m,k,x;
string s;
queue<int> q;
int main(){
cin>>n>>m>>k>>x;
cin>>s;
int cl=0;
while(pow(k,cl)<x) cl++;
for(int i=0;i<m-cl;i++) q.push(1);
int clc=cl;
cl=pow(k,cl-1);
for(int i=0;i<clc;i++){
for(int i=1;i<=k+1;i++){
if(i*cl>=x){
q.push(i);
x-=i*cl;
cl/=k;
break;
}
}
}
string ss;
for(int i=0;i<n;i++){
if(s[i]!='#') cout<<s[i];
else{
cin>>ss;
sort(ss.begin(),ss.end());
cout<<ss[q.front()-1];
q.pop();
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
4 ms |
256 KB |
Output is correct |
6 |
Correct |
5 ms |
256 KB |
Output is correct |
7 |
Incorrect |
5 ms |
256 KB |
Output isn't correct |
8 |
Incorrect |
6 ms |
256 KB |
Output isn't correct |
9 |
Incorrect |
5 ms |
256 KB |
Output isn't correct |
10 |
Incorrect |
5 ms |
256 KB |
Output isn't correct |