Submission #631501

#TimeUsernameProblemLanguageResultExecution timeMemory
631501berrTavan (COCI16_tavan)C++17
80 / 80
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, m, k, x; cin>>n>>m>>k>>x; string t,s; cin>>t; s.clear(); vector<char> v; vector<string> q(m); for(int i=0; i<m; i++) { cin>>s; sort(s.begin(), s.end()); q[i]=s; } int l=1; vector<int> poww(m+1); poww[m-1]=1; for(int i=m-2; i>=0; i--) { poww[i]=poww[i+1]*k; if(poww[i]>1e9||poww[i]<0) poww[i]=-1; } for(int i=0; i<m; i++) { if(poww[i]==-1) { v.push_back(q[i][0]); } else { int p=(x-l)/poww[i]; l+=p*poww[i]; v.push_back(q[i][p]); } } l=0; for(int i=0; i<n; i++) { if(t[i]=='#') { t[i]=v[l]; l++; } } cout<<t<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...