# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
94136 | hamzqq9 | Tavan (COCI16_tavan) | C++14 | 2 ms | 504 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 st first
#define nd second
#define pb push_back
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)/2)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 1000000000000000000ll
#define MOD 1000000007
#define N 505
#define M 15000005
#define LOG 20
#define KOK 650
#define EPS 0.00001
using namespace std;
int n,m,k,x;
int len[N],suf[N];
char mn[N],let[N];
char s[N][29];
int mul(int x,int y) {
if(1ll*x*y>=1000000000) return 1000000001;
return x*y;
}
int main() {
//freopen("input.txt","r",stdin);
scanf("%d %d %d %d",&n,&m,&k,&x);
scanf("%s",mn+1);
for(int i=1;i<=m;i++) {
scanf("%s",s[i]+1);
len[i]=strlen(s[i]+1);
sort(s[i]+1,s[i]+1+len[i]);
}
suf[m+1]=1;
for(int i=m;i>=1;i--) {
suf[i]=mul(suf[i+1],len[i]);
}
for(int i=1;i<=m;i++) {
for(int j=1;j<=len[i];j++) {
if(suf[i+1]<x) {
x-=suf[i+1];
}
else {
let[i]=s[i][j];
break ;
}
}
}
int ptr=1;
for(int i=1;i<=n;i++) {
if(mn[i]=='#') {
mn[i]=let[ptr++];
}
printf("%c",mn[i]);
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |