アルゴリズム
C++ テンプレート
テンプレート
AtCoder Library を前提としたコンテスト用テンプレート。問題ごとに solve() の中身を書く。
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
// --- 型エイリアス ---
using ll = long long;
using i_i = pair<int, int>;
using l_l = pair<ll, ll>;
using mint = modint998244353;
// --- マクロ ---
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define drep(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define pcnt __builtin_popcount
const ll INF = 1e18;
// --- ユーティリティ ---
template<class S, class T> inline bool chmax(S& a, T b) { if (b > a) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S& a, T b) { if (b < a) { a = b; return 1; } return 0; }
// --- 大文字変換 ---
inline char to_upper(char c) { return static_cast<char>(toupper(static_cast<unsigned char>(c))); }
inline string to_upper(string s) {
for (char &c : s) c = to_upper(c);
return s;
}
// --- 小文字変換 ---
inline char to_lower(char c) { return static_cast<char>(tolower(static_cast<unsigned char>(c))); }
inline string to_lower(string s) {
for (char &c : s) c = to_lower(c);
return s;
}
// --- 入出力オーバーロード ---
template <typename T, typename U>
istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.first << " " << p.second; return os; }
template <typename T>
istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
rep(i, sz(v)) os << v[i] << (i + 1 == sz(v) ? "" : " ");
return os;
}
// ====================================================================
void solve() {
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}