Submission #94173

# Submission time Handle Problem Language Result Execution time Memory
94173 2019-01-16T12:25:00 Z Yigit Tavan (COCI16_tavan) C++14
8 / 80
1000 ms 504 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{
			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

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 Incorrect 2 ms 376 KB Output isn't correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Correct 2 ms 376 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Incorrect 2 ms 256 KB Output isn't correct
7 Runtime error 2 ms 504 KB Execution killed with signal 8 (could be triggered by violating memory limits)
8 Execution timed out 1072 ms 376 KB Time limit exceeded
9 Execution timed out 1080 ms 252 KB Time limit exceeded
10 Runtime error 2 ms 380 KB Execution killed with signal 8 (could be triggered by violating memory limits)