Submission #94192

# Submission time Handle Problem Language Result Execution time Memory
94192 2019-01-16T13:09:59 Z bkinik Tavan (COCI16_tavan) C++14
80 / 80
2 ms 404 KB
#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
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 404 KB Output is correct
10 Correct 2 ms 256 KB Output is correct