Submission #1256209

#TimeUsernameProblemLanguageResultExecution timeMemory
1256209nanaseyuzukiProsjecni (COCI16_prosjecni)C++20
120 / 120
2 ms840 KiB
#include <bits/stdc++.h> /* --> Author: Kazuki_Hoshino__8703 <-- I love Nanasaki Ai ☆*: .。. o(≧▽≦)o .。.:*☆ */ #define fi first #define se second #define pii pair<int, int> #define ll long long using namespace std; const int mn = 1e3 + 5, bm = (1 << 15) + 1, mod = 1e9 + 7; const ll inf = 1e9 + 7, base = 311; int n, a[mn][mn]; void solve(){ cin >> n; if(n == 2){ cout << -1 << '\n'; return; } for(int i = 1; i <= n - 1; i++){ a[1][i] = i; } a[1][n] = n * (n - 1) / 2; for(int i = 2; i < n; i++){ for(int j = 1; j <= n; j++){ a[i][j] = a[i - 1][j] + n * (n - 1) / 2; } } for(int j = 1; j <= n; j++){ int total = 0; for(int i = 1; i < n; i++) total += a[i][j]; a[n][j] = n * a[n - 1][j] - total; } for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++){ cout << a[i][j] << ' '; } cout << '\n'; } } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); if(fopen("ROBOT.INP", "r")){ freopen("ROBOT.INP", "r", stdin); freopen("ROBOT.OUT", "w", stdout); } int t = 1; // cin >> t; while(t --){ solve(); } }

Compilation message (stderr)

prosjecni.cpp: In function 'int main()':
prosjecni.cpp:49:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |         freopen("ROBOT.INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
prosjecni.cpp:50:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |         freopen("ROBOT.OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...