답안 #734202

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
734202 2023-05-02T04:34:36 Z rahulverma Prosjecni (COCI16_prosjecni) Java 11
24 / 120
538 ms 14692 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];
			}
			arr[i][n-1] = (int) ((arr[i][n/2] * (n)) - soFar);
			last = arr[i][n-1];
		}
		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();
		}
		
	}

}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 126 ms 10832 KB Average condition doesn't hold.
2 Correct 132 ms 10836 KB Output is correct
3 Incorrect 130 ms 11044 KB Average condition doesn't hold.
4 Correct 141 ms 11144 KB Output is correct
5 Incorrect 139 ms 11040 KB Average condition doesn't hold.
6 Incorrect 171 ms 11068 KB Average condition doesn't hold.
7 Incorrect 275 ms 11944 KB Average condition doesn't hold.
8 Incorrect 342 ms 13332 KB Average condition doesn't hold.
9 Incorrect 343 ms 13104 KB Average condition doesn't hold.
10 Incorrect 538 ms 14692 KB Average condition doesn't hold.