Submission #82385

# Submission time Handle Problem Language Result Execution time Memory
82385 2018-10-30T11:26:39 Z farukkastamonuda Prosjecni (COCI16_prosjecni) C++14
120 / 120
3 ms 812 KB
#include <cstdio>
 
int main() {
    int n;
    scanf("%d", &n);
 
    if (n == 2) {
        printf("-1\n");
    } else if (n % 2 == 1) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                printf("%d%c", i*n+j+1, j==n-1 ? '\n' : ' ');
            }
        }
    } else {
        int k = n / 2;
        for (int i = 0; i < n - 1; i++) {
            for (int j = 0; j < n - 1; j++) {
                printf("%d ", 3*k*i+j+1);
            }
            printf("%d\n", 3*k*(i+1));
        }
        for (int j = 0; j < n - 1; j++) {
            printf("%d ", 9*k*k-3*k+j+1);
        }
        printf("%d\n", 9*k*k);
    }
 
    return 0;
}

Compilation message

prosjecni.cpp: In function 'int main()':
prosjecni.cpp:5:10: 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 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 392 KB Output is correct
3 Correct 2 ms 392 KB Output is correct
4 Correct 2 ms 412 KB Output is correct
5 Correct 2 ms 596 KB Output is correct
6 Correct 2 ms 596 KB Output is correct
7 Correct 2 ms 700 KB Output is correct
8 Correct 3 ms 700 KB Output is correct
9 Correct 3 ms 700 KB Output is correct
10 Correct 3 ms 812 KB Output is correct