# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
94192 | bkinik | Tavan (COCI16_tavan) | C++14 | 2 ms | 404 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;
#define pob pop_back
#define mp make_pair
#define pb push_back
#define mid (l+r)/2
#define test printf("test\n")
#define st first
#define nd second
#define superman ios::sync_with_stdio(0);cin.tie(0);
typedef long long ll;
typedef pair<ll,ll> pll;
ll INF = 1e9;
ll mod = 1e9+7;
double pi = acos(-1);
ll l,k,m,n,r;
ll x;
vector<string> cs;
string ans = "";
int main() {
//freopen(".gir","r",stdin);
//freopen(".cik","w",stdout);
cin>>n>>m>>k>>x;
/*
n = length
m = # of illegible letters
k = # of candidates;
x = alphabetical order
*/
string str;
cin>>str;
cs.resize(m);
string tempstr;
for(int i=0; i<m; i++) {
cin>>cs[i];
sort(cs[i].begin(), cs[i].end());
}
ll na;
for(int i=0; i<m-1; i++) {
na = pow(k,m-i-1);
ans += cs[i][ll(x/na)];
x -= na * (x/na);
}
ans += cs[m-1][x-1];
ll left = 0;
for(int i=0; i<n; i++) {
if(str[i] != '#') cout<<str[i];
else cout<<ans[left++];
}
cout<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |