# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
166635 |
2019-12-03T10:31:38 Z |
Atill83 |
Tavan (COCI16_tavan) |
C++14 |
|
20 ms |
16760 KB |
#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 |
1 |
Correct |
18 ms |
16760 KB |
Output is correct |
2 |
Correct |
17 ms |
16760 KB |
Output is correct |
3 |
Correct |
19 ms |
16760 KB |
Output is correct |
4 |
Correct |
20 ms |
16760 KB |
Output is correct |
5 |
Correct |
17 ms |
16760 KB |
Output is correct |
6 |
Correct |
19 ms |
16760 KB |
Output is correct |
7 |
Correct |
17 ms |
16760 KB |
Output is correct |
8 |
Correct |
19 ms |
16760 KB |
Output is correct |
9 |
Correct |
17 ms |
16760 KB |
Output is correct |
10 |
Correct |
19 ms |
16760 KB |
Output is correct |