Submission #94165

# Submission time Handle Problem Language Result Execution time Memory
94165 2019-01-16T12:12:02 Z Yigit Tavan (COCI16_tavan) C++14
48 / 80
1000 ms 376 KB
#include<bits/stdc++.h>
using namespace std;


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(){
    int n,hata,uzun,inci,i,m,us;
	char tab[501][26];
	char ana[100000];
	scanf("%d",&n);
	scanf("%d",&hata);
	scanf("%d",&uzun);
	scanf("%d",&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("%d",&n);
  ~~~~~^~~~~~~~~
tavan.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&hata);
  ~~~~~^~~~~~~~~~~~
tavan.cpp:27:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&uzun);
  ~~~~~^~~~~~~~~~~~
tavan.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&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 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 1 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 1069 ms 256 KB Time limit exceeded
8 Incorrect 2 ms 376 KB Output isn't correct
9 Incorrect 2 ms 376 KB Output isn't correct
10 Execution timed out 1071 ms 376 KB Time limit exceeded