Submission #209095

# Submission time Handle Problem Language Result Execution time Memory
209095 2020-03-13T07:38:16 Z ArKCa Tavan (COCI16_tavan) C++17
64 / 80
8 ms 3576 KB
 #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);
			// carp=pow(26,m-(say));
			// printf("%lld %lld %lld\n",carp,carp*(sa),x);
			// carp=1;
			if(x==1){
				printf("%c",ss[say][0] );
				say++;
				continue;
			}
			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", x);
			while(sa>k){

			}
			printf("%c",ss[say][sa-1] );
			// cout<<ss[say][sa-1];
			say++;
		}
		else{
			printf("%c",s[j] );
		}
	}
	/*for(char ala='a';ala<='z';ala++){
		// printf("%c",ala );
			cout<<ala;
	}*/
}
/*	
((26^6)*4)+((26^5)*7)+((26^4)*5)+((26^3)*8)+((26^2)*20)+((26^1)*25)+((26^0)*12)
1321272406
*/

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);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 3576 KB Output is correct
2 Correct 7 ms 3448 KB Output is correct
3 Correct 6 ms 3448 KB Output is correct
4 Correct 6 ms 3448 KB Output is correct
5 Correct 7 ms 3448 KB Output is correct
6 Correct 7 ms 3448 KB Output is correct
7 Incorrect 7 ms 3448 KB Output isn't correct
8 Incorrect 7 ms 3448 KB Output isn't correct
9 Correct 7 ms 3448 KB Output is correct
10 Correct 8 ms 3448 KB Output is correct