Submission #734201

# Submission time Handle Problem Language Result Execution time Memory
734201 2023-05-02T04:33:37 Z rahulverma Prosjecni (COCI16_prosjecni) Java 11
24 / 120
529 ms 14672 KB
import java.io.*;
import java.util.*;

public class prosjecni {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		if(n == 2) {
			System.out.println(-1);
			return;
		}
		int[][] arr = new int[n][n];
		int last = 0;
		for(int i = 0; i < n - 1; i++) {
			arr[i][0] = last + 1;
			long soFar = arr[i][0];
			for(int j = 1; j < n - 1; j++) {
				arr[i][j] = arr[i][j-1]+1;
				soFar += arr[i][j];
				last = arr[i][j];
			}
			last++;
			arr[i][n-1] = (int) ((arr[i][n/2] * (n)) - soFar);
		}
		long cols = 0;
		for(int i = 0; i < n; i++) cols += arr[i][0];
		arr[n-1][0] = (int) ((arr[n/2][0] * (n)) - cols);
		for(int i = 1; i < n; i++) {
			arr[n-1][i] = arr[n-1][i-1] + 1;
		}
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				System.out.print(arr[i][j] + " ");
			}
			System.out.println();
		}
		
	}

}
# Verdict Execution time Memory Grader output
1 Incorrect 136 ms 11240 KB Not distinct
2 Correct 119 ms 11008 KB Output is correct
3 Incorrect 131 ms 11032 KB Not distinct
4 Correct 161 ms 10916 KB Output is correct
5 Incorrect 138 ms 11068 KB Not distinct
6 Incorrect 166 ms 11440 KB Not distinct
7 Incorrect 242 ms 11896 KB Not distinct
8 Incorrect 334 ms 13372 KB Not distinct
9 Incorrect 349 ms 13356 KB Not distinct
10 Incorrect 529 ms 14672 KB Not distinct