# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
156503 | Moses | Prosjecni (COCI16_prosjecni) | C++14 | 3 ms | 504 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Created by AboAbdoMC
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const int OO = 1e9+7;
const int MOD = 1e9+7;
const int N = 1e2+7;
int ans[N][N];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
if (n%2 == 1)
{
int cnt = 1;
rep(i,n)
{
rep(j,n) {cout << cnt << ' ';cnt++;}
cout << '\n';
}
return 0;
}
rep(i,n)
{
ans[0][i] = i+1;
}
ans[0][n-1] = (n*(n-1))/2;
repA(i,1,n-2)
{
rep(j,n)
{
ans[i][j] = ans[i-1][j]+(n*(n-1))/2;
}
}
rep(j,n)
{
int sum = 0;
rep(i,n-1) sum += ans[i][j];
ans[n-1][j] = n*ans[n-2][j] - sum;
}
rep(i,n) {rep(j,n) cout << ans[i][j] << ' '; cout << '\n';}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |