# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
166635 | Atill83 | Tavan (COCI16_tavan) | C++14 | 20 ms | 16760 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>
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |