Submission #209131

# Submission time Handle Problem Language Result Execution time Memory
209131 2020-03-13T09:03:52 Z ArKCa Prosjecni (COCI16_prosjecni) C++17
120 / 120
6 ms 376 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    1000006
#define  mod  1000000007

using namespace std;


int n;
int dizi[500],dizim[500],sum;
int32_t main(){	    
	 // freopen("a.gir","r",stdin);
	// freopen("a.cik","w",stdout);
   //
  // 
	scanf("%lld" ,&n);
	if(n==2){
		printf("-1\n" );
		return 0;
	}
	if(n%2==1){
		for(int i=1;i<=n*n;i++){
			printf("%lld ",i);
			if(i%n==0)printf("\n");
		}
		return 0;
	}
	int sa=1;
	for(int i=0;i<(n-1);i++){
		sum=0;
		for(int j=0;j<(n-1);j++){
			printf("%lld ", sa);
			sum+=sa;
			dizi[j]+=sa;
			dizim[j]=sa;
			sa++;
		}
		printf("%lld\n",((sa-1)*n)-sum );
		sa=((sa-1)*n)-sum;
		sa++;
	}
	sum=0;

	for(int i=0;i<(n-1);i++){
		printf("%lld ",dizim[i]*n-dizi[i] );
		sum+=dizim[i]*n-dizi[i];
		sa=dizim[i]*n-dizi[i];
	}
	printf("%lld\n",sa*n-sum );

}


Compilation message

prosjecni.cpp: In function 'int32_t main()':
prosjecni.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld" ,&n);
  ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 6 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 6 ms 376 KB Output is correct