Submission #94187

# Submission time Handle Problem Language Result Execution time Memory
94187 2019-01-16T12:50:59 Z hamzqq9 Prosjecni (COCI16_prosjecni) C++14
0 / 120
10 ms 504 KB
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)/2)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 1000000000000000000ll
#define MOD 1000000007
#define N 1000006
#define M 15000005
#define LOG 20
#define KOK 650
#define EPS 0.00001
using namespace std;

int n;
int val[105][105],row[105],col[105];

int main() {

	//freopen("input.txt","r",stdin);

	scanf("%d",&n);

	if(n&1) {

		for(int i=0;i<n;i++) {

			for(int j=0;j<n;j++) {

				printf("%d ",2*((j+i)%n+1));

			}

			puts("");

		}

		return 0;

	}

	if(n==2) {

		printf("-1");
	
	}

	int cur=1;
	int add=n-1;

	for(int i=1;i<n;i++) {

		for(int j=1;j<n;j++) {

			val[i][j]=cur;

			row[i]+=cur;
			col[j]+=cur;

			cur+=add;

			add+=n-1;

		}

	}

	for(int i=1;i<=n;i++) {

		val[i][n]=row[i]/(n-1);
		val[n][i]=col[i]/(n-1);

	}

	for(int i=1;i<=n;i++) {

		for(int j=1;j<=n;j++) {

			printf("%d ",val[i][j]);

		}

		puts("");

	}

}

Compilation message

prosjecni.cpp: In function 'int main()':
prosjecni.cpp:35:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Average condition doesn't hold.
2 Incorrect 2 ms 376 KB Not distinct
3 Incorrect 2 ms 256 KB Not distinct
4 Incorrect 2 ms 376 KB Not distinct
5 Incorrect 2 ms 376 KB Average condition doesn't hold.
6 Incorrect 2 ms 376 KB Integer -50985438 violates the range [0, 1000000000]
7 Incorrect 2 ms 376 KB Integer -28681658 violates the range [0, 1000000000]
8 Incorrect 10 ms 376 KB Integer -17091547 violates the range [0, 1000000000]
9 Incorrect 2 ms 504 KB Integer -18571072 violates the range [0, 1000000000]
10 Incorrect 2 ms 504 KB Integer -16053435 violates the range [0, 1000000000]