제출 #146747

#제출 시각아이디문제언어결과실행 시간메모리
146747fran_1024Prosjecni (COCI16_prosjecni)C++14
120 / 120
4 ms380 KiB
#include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; int x = n * n; if(x == 4) { cout << -1; return 0; } int m = 0; if(n & 1) for(int i = 0; i < x; i++) { cout << i + 1 << ' '; if((i + 1) % n == 0) { cout << '\n'; } } else { vector <int> ar(n); for(int i = 0; i < n; i++) { ar[i] = i + 1; } int x = ar[n / 2] * n - (n * (n - 1) / 2); ar[n - 1] = x; int fsum = 0; int nkd; for(int i = 0; i < n; i++) { if(i == n - 1) { int y = nkd * n - fsum; for(int j = 0; j < n; j++) { ar[j] = y + j; if(j == n - 1) { ar[j] += x - j - 1; } } } fsum += ar[0]; if(i == n / 2) nkd = ar[0]; for(int j = 0; j < n; j++) { cout << ar[j] << ' '; ar[j] += x; } cout << '\n'; } } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

prosjecni.cpp: In function 'int main()':
prosjecni.cpp:13:6: warning: unused variable 'm' [-Wunused-variable]
  int m = 0;
      ^
prosjecni.cpp:32:17: warning: 'nkd' may be used uninitialized in this function [-Wmaybe-uninitialized]
     int y = nkd * n - fsum;
             ~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...