제출 #208895

#제출 시각아이디문제언어결과실행 시간메모리
208895DysonSphereTavan (COCI16_tavan)C++14
80 / 80
5 ms376 KiB
#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 timeMemoryGrader output
Fetching results...