# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
209076 | ArKCa | Tavan (COCI16_tavan) | C++17 | 1097 ms | 3452 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 f1 first
#define s2 second
#define pb push_back
#define pob pop_back
#define int ll
#define ll long long
#define PII pair<int,int>
#define N 100005
#define mod 1000000007
using namespace std;
int n,m,k,x;
string s,ss[N];
int32_t main(){
// freopen("a.gir","r",stdin);
// freopen("a.cik","w",stdout);
//
//
scanf("%lld %lld %lld %lld" ,&n,&m,&k,&x);
cin>>s;
for(int i=1;i<=m;i++){
cin>>ss[i];
sort(ss[i].begin(), ss[i].end());
}
int carp=1,i;
for(i=m;i>0;i--){
if(carp>x){
break;
}
carp*=k;
}
int say=1,j;
for(j=0;say<=i;j++){
if(s[j]=='#'){
printf("%c",ss[say][0] );
say++;
}
else{
printf("%c",s[j] );
}
}
int sa;
for(;j<n;j++){
if(s[j]=='#'){
// printf("%lld\n",carp);
carp/=k;
sa=1;
// printf("%lld\n", x);
// printf("%lld\n",carp);
A:
if((carp*sa)<x && (carp*(sa+1))>=x ){
x-=carp*sa;
sa++;
}
else if((carp*sa)==x){
x-=carp*(sa-1);
}
else if(sa<=k){
sa++;
goto A;
}
// printf("%lld\n", sa);
while(sa>k){
}
printf("%c",ss[say][sa-1] );
// cout<<ss[say][sa-1];
say++;
}
else{
printf("%c",s[j] );
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |