-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1236C.cpp
50 lines (48 loc) · 1.09 KB
/
1236C.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "bits/stdc++.h"
#pragma GCC optimize "trapv"
using i64 = long long int;
using namespace std;
int nxt(){int x; cin >> x; return x;}
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define inarr(a,n) for(int i = 0; i < n; ++i) cin >> a[i];
//
#ifndef ONLINE_JUDGE
#include "debug.hpp"
#else
#define print(...)
#define debug(...)
#endif
int a[301][301];
void solve(){
int n; cin >> n;
int cnt = 1;
for(int i = 0;i < n; i += 2) {
for(int j = 0; j < n; j++) {
a[j][i] = cnt;
cnt++;
}
cnt += n;
}
cnt = n + 1;
for(int i = 1;i < n; i += 2) {
for(int j = n - 1; j >= 0; j--) {
a[j][i] = cnt;
cnt++;
}
cnt += n;
}
for(int i = 0; i < n; ++i) {
for(int j = 0; j < n; ++j) cout << a[i][j] << " ";
cout << "\n";
}
}
int main(){
ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
int testt = 1;
// cin >> testt;
for (int i = 1; i <= testt; ++i){
// cout << "Case #" << i << ": ";
solve();
}
}