-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathC.cpp
More file actions
50 lines (40 loc) · 1.65 KB
/
Copy pathC.cpp
File metadata and controls
50 lines (40 loc) · 1.65 KB
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>
using namespace std;
#ifndef HELLO_PEOPLE
#define cerr if(0) cout
#endif
using ll = long long;
using ld = long double;
#define all(v) (v).begin(), (v).end()
#define X first
#define Y second
template<class T> struct Nit { T _v, _s; Nit(T v, T s) : _v(v), _s(s) {} operator T &() { return _v; } T operator *() const { return _v; } Nit &operator++() { _v += _s; return *this; } bool operator!=(Nit &a) { return (_s > 0 ? _v < a._v : _v >= a._v);} };
template<class T = int> struct range { T _b, _e, _s; range(T e) : _b(0), _e(e), _s(1) {} range(T b, T e, T s = 1) : _b(b), _e(e), _s(s) {} Nit<T> begin() { return Nit<T>(_b, _s); } Nit<T> end() { return Nit<T>(_e, _s); } };
template<class T = int> struct rrange : range<T> { rrange(T e, T b, T s = 1) : range<T>(e, b, -s) {} rrange(T e) : range<T>(e, 0, -1) {} };
template<int D, class T> struct vec : public vector<vec<D - 1, T>> { template<class... Args> vec(int n = 0, Args... a) : vector<vec<D - 1, T>>(n, vec<D - 1, T>(a...)) {} };
template<class T> struct vec<1, T> : public vector<T> { vec(int n = 0, T const &val = T()) : vector<T>(n, val) {} };
// now start
ll const INF = 1e14;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
int par = 0;
vec<2, int> gp(n);
for (auto j : range(n)) {
vector<int> now(n);
iota(all(now), j * n + 1);
int p = 0;
for (auto i : (par ? range(n) : rrange(n - 1))) {
gp[p].emplace_back(now[i]);
p++;
}
par = !par;
}
for (auto i : range(n)) {
for (auto &j : gp[i]) cout << j << ' ';
cout << '\n';
}
return 0;
}