Submission #84033

#TimeUsernameProblemLanguageResultExecution timeMemory
84033wjoaoProsjecni (COCI16_prosjecni)C++11
120 / 120
3 ms668 KiB
#include<bits/stdc++.h> using namespace std; int n; int main(){ scanf(" %d", &n); if( n == 1 ) printf("1\n"); else if( n == 2 ) printf("-1\n"); else if (n%2 == 1){ for(int i = 0, k = 1; i < n; i++){ for(int j = 0; j < n; j++, k++){ if( j != 0 ) printf(" "); printf("%d", k); } printf("\n"); } }else{ vector<int> ind; int meio = n*100*100; ind.push_back(0); for(int i = 1; i <= n/2; i++) ind.push_back(-i); for(int i = 1; i <= n/2-2; i++) ind.push_back(i); ind.push_back(n-1); for(int i = 0; i < n; i++){ int atual = meio + ind[i]*2*n; for(int j = 0; j < n; j++){ if( j != 0 ) printf(" "); printf("%d", atual + ind[j]); }printf("\n"); } } return 0; }

Compilation message (stderr)

prosjecni.cpp: In function 'int main()':
prosjecni.cpp:8:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %d", &n);
   ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...