# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
208895 | DysonSphere | Tavan (COCI16_tavan) | C++14 | 5 ms | 376 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
int main(){
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int n,m,k,x;
cin>>n>>m>>k>>x;
x--;
string smain;
cin>>smain;
string arr[m];
for(int i=0;i<m;i++){
cin>>arr[i];
sort(arr[i].begin(), arr[i].end());
}
int inds[m];
for(int i=0;i<m;i++){
inds[i]=-1;
}
long long int mults[m];
mults[m-1]=1;
for(int i=m-2;i>=0;i--){
mults[i]=mults[i+1]*k;
if(mults[i]>x){
for(int j=0;j<=i;j++){
inds[j]=0;
}
break;
}
}
for(int i=0;i<m;i++){
if(inds[i]==-1){
int mul=0,ind=-1;
while(x>=mul){
ind++;
mul+=mults[i];
}
mul-=mults[i];
inds[i]=ind;
x-=mul;
}
}
for(int i=0,ind=0;i<n;i++){
if(smain[i]!='#'){
cout<<smain[i];
}
else{
cout<<arr[ind][inds[ind]];
ind++;
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |