Repository navigation
Expand file tree
/
Copy pathtemplate.cpp
More file actions
213 lines (191 loc) · 4.7 KB
/
Copy pathtemplate.cpp
File metadata and controls
213 lines (191 loc) · 4.7 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
// 数値型
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int,int>;
using Pll = pair<ll, ll>;
using Pli = pair<ll, int>;
using Pil = pair<int, ll>;
// vector関連
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
template<typename T>
using vc = vector<T>;
template<typename T>
using vvc = vector<vc<T>>;
template<typename T>
using vvvc = vector<vvc<T>>;
template<typename T>
using vvvvc = vector<vvvc<T>>;
// priority_queue
template<typename T>
using pq = priority_queue<T>;
template<typename T>
using pqg = priority_queue<T, vc<T>, greater<T>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = a; i < (int)(b); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MIN(vec) *min_element(vec)
#define MAX(vec) *max_element(vec)
#define next_perm(vec) next_permutation((vec).begin(), (vec).end())
#define UNIQUE(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define el "\n"
#define Yes cout << "Yes" << el
#define No cout << "No" << el
#define YES cout << "YES" << el
#define NO cout << "NO" << el
#define EPS 1e-8
#define Equal(a, b) (fabs((a)-(b)) < EPS)
#define dbg(x) cerr << #x << "=" << x << el
// 定数
const string abc = "abcdefghijklmnopqrstuvwxyz";
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
constexpr int INF = 1001001001;
constexpr ll LINF = 1001001001001001001ll;
constexpr int DX[] = {1, 0, -1, 0};
constexpr int DY[] = {0, 1, 0, -1};
constexpr int DX8[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int DY8[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<typename T1, typename T2>
ostream &operator<< (ostream &os, pair<T1, T2> p) {
os << "{" << p.first << "," << p.second << "}";
return os;
}
template<typename T>
ostream &operator<< (ostream &os, vc<T> &vec) {
int sz = vec.size();
rep(i, sz){
os << vec[i] << (i==sz-1?"":" ");
}
return os;
}
template<typename T1, typename T2>
istream &operator>> (istream &is, pair<T1, T2> &p) {
is >> p.first >> p.second;
return is;
}
template<typename T>
istream &operator>> (istream &is, vc<T> &vec) {
int sz = vec.size();
rep(i, sz) { is >> vec[i]; }
return is;
}
/// @brief aとbの最大値をaに格納。更新があったかbool値を返す
/// @tparam T1
/// @tparam T2
/// @param a
/// @param b
/// @return bool
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b){
bool ret = a<b;
if(ret) a = b;
return ret;
}
/// @brief aとbの最小値をaに格納。更新があったかbool値を返す
/// @tparam T1
/// @tparam T2
/// @param a
/// @param b
/// @return bool
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b){
bool ret = a>b;
if(ret) {a = b;}
return ret;
}
inline void YesNo(bool flag){
if(flag) {Yes;}
else {No;}
return;
}
inline void YESNO(bool flag){
if(flag) {YES;}
else {NO;}
return;
}
inline bool outof(ll x, ll xlim){
return (x<0 || x>=xlim);
}
template<typename T>
inline T sqnorm(T x, T y){
return x*x+y*y;
}
/// @brief char->int
/// @param c
/// @return int
inline int ctoi(char c){
return c-'0';
}
/// @brief xを素因数分解
/// @param x
/// @return vector<Pli>, 素因数の昇順に {p, cnt}
vector<Pli> prime_fact(ll x){
vector<Pli> ret;
for(ll i=2; i*i<=x; i++){
if(x%i == 0){
ret.emplace_back(i, 0);
while(x%i == 0){
ret.back().second++;
x /= i;
}
}
}
if(x != 1) ret.emplace_back(x, 1);
return ret;
}
/// @brief xの約数列挙
/// @param x
/// @return vll, 約数の昇順
vll divisor_enum(ll x){
vector<ll> ret;
for(ll i=1; i*i<=x; i++){
if(x%i == 0){
ret.push_back(x/i);
ret.push_back(i);
}
}
sort(all(ret));
UNIQUE(ret);
return ret;
}
/// @brief 繰り返し二乗法。
/// @tparam T
/// @param x
/// @param k
/// @param op
/// @param e
/// @return
template<typename T>
T pow_t(T x, ll k, T (*op)(T, T), T (*e)()){
T ret = e();
while(k){
if(k&1) ret = op(ret, x);
x = op(x, x);
k >>= 1;
}
return ret;
}
ll powll(ll x, ll k){
return pow_t<ll>(x, k, [](ll a, ll b) -> ll{return a*b;}, []() -> ll{return 1;});
}
inline int pop_cnt(ll x) { return __builtin_popcountll(x); }
inline int top_bit(ll x) { return (x==0?-1:63-__builtin_clzll(x));}
void main2();
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
main2();
}
void main2(){
}