Submission #166635

#TimeUsernameProblemLanguageResultExecution timeMemory
166635Atill83Tavan (COCI16_tavan)C++14
80 / 80
20 ms16760 KiB
#include <bits/stdc++.h> #define ff first #define ss second #define endl '\n' using namespace std; const long long INF = (long long) 1e18; const int mod = (int) 1e9+7; const int MAXN = (int) 3e5+5; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; typedef pair<ll,ll> pll; ll n, m, k, x; string s; vector<char> yer[MAXN]; string ss[MAXN]; ll kpow[MAXN]; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr);cout.tie(nullptr); #ifdef Local freopen("../IO/int.txt","r",stdin); freopen("../IO/out.txt","w",stdout); #endif cin>>n>>m>>k>>x; cin>>s; x--; for(int i = 0; i < m; i++){ cin>>ss[i]; sort(ss[i].begin(), ss[i].end()); } kpow[0] = 1; for(int i = 1; i < m; i++){ kpow[i] = kpow[i - 1]*k; kpow[i] = min(kpow[i], (ll)2e9); } int cnt = 0; for(int i = 0; i < n; i++){ if(s[i] == '#'){ cnt++; ll res = kpow[m - cnt]; ll yer = x / res; //cout<<res<<endl; x = x%res; s[i] = ss[cnt - 1][yer]; } } cout<<s<<endl; #ifdef Local cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds "; #endif }
#Verdict Execution timeMemoryGrader output
Fetching results...