#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[1000];
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;
}
/*if(carp==x){
int say=0,j;
for(j=0;say<=i;j++){
if(s[j]=='#'){
printf("%c",ss[say+1][0] );
say++;
}
else{
printf("%c",s[j] );
}
}
for(;j<n;j++){
if(s[j]=='#'){
printf("%c",ss[say][k-1] );
say++;
}
else{
printf("%c",s[j] );
}
}
return 0;
}*/
int say=0,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]=='#'){
carp/=k;
sa=1;
A:
// printf("%lld\n",carp);
if((carp*sa)<x &&(carp*(sa+1))>=x ){
x-=k*sa;
sa++;
// printf("%lld\n", x);
}
else if((carp*sa)==x){
x-=k*(sa-1);
}
else if(sa<=k){
sa++;
goto A;
}
// printf("%lld\n", sa);
printf("%c",ss[say+1][sa-1] );
// cout<<ss[say][sa-1];
say++;
}
else{
printf("%c",s[j] );
}
}
}
Compilation message
tavan.cpp: In function 'int32_t main()':
tavan.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld %lld %lld %lld" ,&n,&m,&k,&x);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
380 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
8 |
Incorrect |
5 ms |
380 KB |
Output isn't correct |
9 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
10 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |