Submission #133664

# Submission time Handle Problem Language Result Execution time Memory
133664 2019-07-21T08:08:05 Z forelax Tavan (COCI16_tavan) C++14
80 / 80
2 ms 504 KB
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,k,x;
    cin>>n>>m>>k>>x;x--;
    string r;
    cin>>r;
    vector<string> g(m);
    for(int i = 0 ; i < m ; i ++){
        cin>>g[i];
        sort(g[i].begin(),g[i].end());
//        cout<<g[i]<<" ";
    }
    vector<int> t(m,0);
    long long psb=k;
    int i=m-1;
//    cout<<i<<" ";
    while(psb<x){
        psb*=k;
        i--;
    }
//    cout<<i<<endl;
    psb/=k;
    while(i<m){
        t[i]=x/psb;
//        cout<<i<<" "<<x<<" "<<psb<<" "<<t[i]<<" "<<x%psb<<endl;
        x%=psb;
        i++;
        psb/=k;
    }
    for(int i = 0,j=0 ; i < n ; i ++){
        if(r[i]=='#'){
//            cout<<endl<<j<<" "<<g[j]<<" "<<t[j]<<endl;
            cout<<g[j][t[j]];
            j++;
        }else cout<<r[i];
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 252 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 380 KB Output is correct