Submission #94167

# Submission time Handle Problem Language Result Execution time Memory
94167 2019-01-16T12:14:52 Z Yigit Tavan (COCI16_tavan) C++14
48 / 80
1000 ms 376 KB
#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{
			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

tavan.cpp: In function 'int main()':
tavan.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&n);
  ~~~~~^~~~~~~~~~~
tavan.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&hata);
  ~~~~~^~~~~~~~~~~~~~
tavan.cpp:27:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&uzun);
  ~~~~~^~~~~~~~~~~~~~
tavan.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&inci);
  ~~~~~^~~~~~~~~~~~~~
tavan.cpp:29:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=0;i<n;i++)scanf(" %c",&ana[i]);
                  ~~~~~^~~~~~~~~~~~~~~
tavan.cpp:32:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf(" %c",&tab[i][m]);
    ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Execution timed out 1082 ms 376 KB Time limit exceeded
8 Execution timed out 1068 ms 376 KB Time limit exceeded
9 Execution timed out 1080 ms 256 KB Time limit exceeded
10 Execution timed out 1078 ms 376 KB Time limit exceeded