# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
94173 | Yigit | Tavan (COCI16_tavan) | C++14 | 1080 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>
using namespace std;
long long int power(int a,int b){
int sonuc=1;
while(b>0){
if(b%2==1){
sonuc*=a;
b--;
}
else{
a=a*a;
b=b/2;
}
}
return sonuc;
}
int main(){
long long int n,hata,uzun,inci,i,m,us;
char tab[505][26];
char ana[100000];
scanf("%lld",&n);
scanf("%lld",&hata);
scanf("%lld",&uzun);
scanf("%lld",&inci);
for(i=0;i<n;i++)scanf(" %c",&ana[i]);
for(i=0;i<hata;i++){
for(m=0;m<uzun;m++){
scanf(" %c",&tab[i][m]);
}
sort(tab[i],tab[i]+uzun);
}
us=power(uzun,hata-1);
int coz[10000],k=0,sira=0;
while(inci>0){
//printf("%d %d\n",us,inci);
if(us==inci && inci==1){
coz[sira]=k;
inci--;
}
if(us>=inci){
us/=uzun;
coz[sira]=k;
k=0;
sira++;
}
else{
if(sira!=uzun-2
){
int hiz;
hiz=inci/us;
inci-=hiz*us;
k+=hiz;
}
else{
inci-=us;
k++;
}
}
}
int l=0;
for(i=0;i<n;i++){
if(ana[i]!='#')printf("%c",ana[i]);
else{
printf("%c",tab[l][coz[l]]);
l++;
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |