Skip to content

Commit 1028974

Browse files
committed
add(cpp): chmin/chmaxを追加
1 parent e7f933a commit 1028974

File tree

1 file changed

+31
-26
lines changed

1 file changed

+31
-26
lines changed

code/main.cpp

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,46 @@ using ull = unsigned long long;
1010
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
1111
#define all(a) (a).begin(), (a).end()
1212

13+
template <typename T> bool chmin(T &a, T b) {
14+
if (a > b) {
15+
a = b;
16+
return true;
17+
}
18+
return false;
19+
}
20+
template <typename T> bool chmax(T &a, T b) {
21+
if (a < b) {
22+
a = b;
23+
return true;
24+
}
25+
return false;
26+
}
27+
1328
void printbase() { cout << '\n'; }
1429

15-
template <typename T>
16-
void printbase(const T &t)
17-
{
18-
cout << t << '\n';
19-
}
30+
template <typename T> void printbase(const T &t) { cout << t << '\n'; }
2031

21-
template <typename T>
22-
void printbase(const std::vector<T> &vec)
23-
{
24-
for (const auto &v : vec)
25-
{
26-
cout << v << ' ';
27-
}
28-
cout << '\n';
32+
template <typename T> void printbase(const std::vector<T> &vec) {
33+
for (const auto &v : vec) {
34+
cout << v << ' ';
35+
}
36+
cout << '\n';
2937
}
3038

3139
template <typename Head, typename... Tail>
32-
void printbase(const Head &head, const Tail &...tail)
33-
{
34-
cout << head << ' ';
35-
printbase(tail...);
40+
void printbase(const Head &head, const Tail &...tail) {
41+
cout << head << ' ';
42+
printbase(tail...);
3643
}
3744

38-
#define print(...) \
39-
{ \
40-
printbase(__VA_ARGS__); \
41-
return 0; \
42-
}
45+
#define print(...) \
46+
{ \
47+
printbase(__VA_ARGS__); \
48+
return 0; \
49+
}
4350

44-
const ll INF = pow(10, 18);
51+
const ll INF = (ll)1 << 63;
4552
const string upperlist = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
4653
const string lowerlist = "abcdefghijklmnopqrstuvwxyz";
4754

48-
int main()
49-
{
50-
}
55+
int main() {}

0 commit comments

Comments
 (0)