結果
問題 | No.2421 entersys? |
ユーザー | 👑 seekworser |
提出日時 | 2023-08-12 14:25:52 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 23,960 bytes |
コンパイル時間 | 3,496 ms |
コンパイル使用メモリ | 254,952 KB |
実行使用メモリ | 61,664 KB |
最終ジャッジ日時 | 2024-11-19 19:20:56 |
合計ジャッジ時間 | 18,435 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | WA | - |
testcase_02 | RE | - |
testcase_03 | WA | - |
testcase_04 | RE | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | RE | - |
testcase_10 | WA | - |
testcase_11 | AC | 702 ms
45,732 KB |
testcase_12 | AC | 677 ms
44,272 KB |
testcase_13 | AC | 684 ms
46,004 KB |
testcase_14 | AC | 695 ms
45,108 KB |
testcase_15 | AC | 705 ms
45,164 KB |
testcase_16 | AC | 739 ms
50,120 KB |
testcase_17 | AC | 723 ms
50,196 KB |
testcase_18 | AC | 711 ms
51,052 KB |
testcase_19 | AC | 739 ms
50,360 KB |
testcase_20 | AC | 730 ms
50,124 KB |
testcase_21 | AC | 506 ms
38,252 KB |
testcase_22 | AC | 569 ms
46,500 KB |
testcase_23 | AC | 1,026 ms
61,664 KB |
testcase_24 | AC | 993 ms
61,640 KB |
testcase_25 | AC | 1,034 ms
61,636 KB |
testcase_26 | AC | 323 ms
27,388 KB |
testcase_27 | AC | 321 ms
27,392 KB |
testcase_28 | AC | 324 ms
27,388 KB |
ソースコード
//line 1 "answer.cpp" #if !__INCLUDE_LEVEL__ #include __FILE__ int main() { ll n; input(n); map<string, set<pll>> mp; vector<ll> ci; debug(n); rep(i, n) { string x; ll l,r; input(x,l,r); ci.emplace_back(l); ci.emplace_back(r+1); mp[x].emplace(l,r); } debug("---"); repe(e, mp) { e.second.emplace(-INFL, -INFL); e.second.emplace(INFL, INFL); } debug("----"); ll q; input(q); vector<tuple<ll,string,ll>> query1; vector<tuple<ll,ll>> query2; vector<tuple<ll,string,ll,ll>> query3; vector<ll> qt(q); rep(i, q) { ll t; input(t); qt[i] = t; if (t == 1) { string x; ll y; input(x,y); query1.emplace_back(i, x, y); } else if (t == 2) { ll ti; input(ti); query2.emplace_back(i, ti); ci.emplace_back(ti); } else { string x; ll l,r; input(x,l,r); query3.emplace_back(i,x,l,r); ci.emplace_back(l); ci.emplace_back(r+1); if (mp[x].empty()) { mp[x].emplace(-INFL, -INFL); mp[x].emplace(INFL, INFL); continue; } } } Compress<ll,ll> c(ci); lseg_max_radd<ll> seg(sz(c)); rep(i, sz(c)) { seg.set(i, 0); } repe(e, mp) { repe(e, e.second) { auto[l,r] = e; if (l == -INFL || l == INFL) continue; debug(l, r); seg.apply(c.pos(l), c.pos(r+1), 1); } } ll id1 = 0, id2 = 0, id3 = 0; rep(i, n) { if (qt[i] == 1) { auto [id, x, t] = query1[id1]; id1++; debug(id, x, t); if (!mp.count(x)) { No(); continue; } auto iter = mp[x].upper_bound(make_pair<ll>((ll)t, INFL)); --iter; auto [l, r] = *iter; Yes(in_range<ll>((ll)t, l, r+1)); } else if (qt[i] == 2) { auto [id, t] = query2[id2]; id2++; debug(id, t); print(seg.get(c.pos(t))); } else { auto [id, x, l, r] = query3[id3]; id3++; debug(id, x, l, r); mp[x].emplace(l, r); seg.apply(c.pos(l), c.pos(r+1),1); } } } #else //line 2 "/home/fujisawa/atcoder/competitive_library/competitive/std/std.hpp" #include <bits/stdc++.h> #ifndef LOCAL_TEST #pragma GCC target ("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #endif // LOCAL_TEST using namespace std; // 型名の短縮 using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>; using vl = vector<ll>; using vvl = vector<vl>; using vvvl = vector<vvl>; using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>; using vc = vector<char>; using vvc = vector<vc>; using vvvc = vector<vvc>; using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>; using vs = vector<string>; using vvs = vector<vector<string>>; using vvvs = vector<vector<vector<string>>>; template<typename T> vector<vector<T>> vv(int h, int w, T val = T()) { return vector(h, vector<T>(w, val)); } template<typename T> vector<vector<vector<T>>> vvv(int h1, int h2, int h3, T val = T()) { return vector(h1, vector(h2, vector<T>(h3, val))); } template<typename T> vector<vector<vector<vector<T>>>> vvvv(int h1, int h2, int h3, int h4, T val = T()) { return vector(h1, vector(h2, vector(h3, vector<T>(h4, val)))); } template <class T> using priority_queue_min = priority_queue<T, vector<T>, greater<T>>; // 定数の定義 constexpr double PI = 3.14159265358979323; constexpr int INF = 100100111; constexpr ll INFL = 3300300300300300491LL; float EPS = 1e-8; double EPSL = 1e-16; template<typename T> bool eq(const T x, const T y) { return x == y; } template<> bool eq<double>(const double x, const double y) { return abs(x - y) < EPSL; } template<> bool eq<float>(const float x, const float y) { return abs(x - y) < EPS; } template<typename T> bool neq(const T x, const T y) { return !(eq<T>(x, y)); } template<typename T> bool ge(const T x, const T y) { return (eq<T>(x, y) || (x > y)); } template<typename T> bool le(const T x, const T y) { return (eq<T>(x, y) || (x < y)); } template<typename T> bool gt(const T x, const T y) { return !(le<T>(x, y)); } template<typename T> bool lt(const T x, const T y) { return !(ge<T>(x, y)); } constexpr int MODINT998244353 = 998244353; constexpr int MODINT1000000007 = 1000000007; // 入出力高速化 struct Nyan { Nyan() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(18); } } nyan; // 汎用マクロの定義 #define all(a) (a).begin(), (a).end() #define sz(x) ((ll)(x).size()) #define rep1(n) for(ll dummy_iter = 0LL; dummy_iter < n; ++dummy_iter) // 0 から n-1 まで昇順 #define rep2(i, n) for(ll i = 0LL, i##_counter = 0LL; i##_counter < ll(n); ++(i##_counter), (i) = i##_counter) // 0 から n-1 まで昇順 #define rep3(i, s, t) for(ll i = ll(s), i##_counter = ll(s); i##_counter < ll(t); ++(i##_counter), (i) = (i##_counter)) // s から t まで昇順 #define rep4(i, s, t, step) for(ll i##_counter = step > 0 ? ll(s) : -ll(s), i##_end = step > 0 ? ll(t) : -ll(t), i##_step = abs(step), i = ll(s); i##_counter < i##_end; i##_counter += i##_step, i = step > 0 ? i##_counter : -i##_counter) // s から t まで stepずつ #define overload4(a, b, c, d, e, ...) e #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #define repe(a, v) for(auto& a : (v)) // v の全要素(変更可能) #define smod(n, m) ((((n) % (m)) + (m)) % (m)) // 非負mod #define sdiv(n, m) (((n) - smod(n, m)) / (m)) // 非負div #define uniq(a) {sort(all(a)); (a).erase(unique(all(a)), (a).end());} // 重複除去 int Yes(bool b=true) { cout << (b ? "Yes\n" : "No\n"); return 0; }; int YES(bool b=true) { cout << (b ? "YES\n" : "NO\n"); return 0; }; int No(bool b=true) {return Yes(!b);}; int NO(bool b=true) {return YES(!b);}; template<typename T, size_t N> T max(array<T, N>& a) { return *max_element(all(a)); }; template<typename T, size_t N> T min(array<T, N>& a) { return *min_element(all(a)); }; template<typename T> T max(vector<T>& a) { return *max_element(all(a)); }; template<typename T> T min(vector<T>& a) { return *min_element(all(a)); }; template<typename T> vector<T> vec_slice(const vector<T>& a, int l, int r) { vector<T> rev; rep(i, l, r) rev.push_back(a[i]); return rev; }; template<typename T> T sum(vector<T>& a, T zero = T(0)) { T rev = zero; rep(i, sz(a)) rev += a[i]; return rev; }; template<typename T> bool in_range(const T& val, const T& s, const T& t) { return s <= val && val < t; }; template <class T> inline vector<T>& operator--(vector<T>& v) { repe(x, v) --x; return v; } template <class T> inline vector<T>& operator++(vector<T>& v) { repe(x, v) ++x; return v; } // modでのpow ll powm(ll a, ll n, ll mod=INFL) { ll res = 1; while (n > 0) { if (n & 1) res = (res * a) % mod; if (n > 1) a = (a * a) % mod; n >>= 1; } return res; } // 整数Sqrt ll sqrtll(ll x) { assert(x >= 0); ll rev = sqrt(x); while(rev * rev > x) --rev; while((rev+1) * (rev+1)<=x) ++rev; return rev; } template <class T> inline bool chmax(T& M, const T& x) { if (M < x) { M = x; return true; } return false; } // 最大値を更新(更新されたら true を返す) template <class T> inline bool chmin(T& m, const T& x) { if (m > x) { m = x; return true; } return false; } // 最小値を更新(更新されたら true を返す) int digit(ll x, int d=10) { int rev=0; while (x > 0) { rev++; x /= d;}; return rev; } // xのd進数桁数 /** * @brief std.hpp * @docs docs/std/std.md */ //line 6 "/home/fujisawa/atcoder/competitive_library/atcoder/lazysegtree.hpp" //line 2 "/home/fujisawa/atcoder/competitive_library/atcoder/internal_bit.hpp" #ifdef _MSC_VER #include <intrin.h> #endif namespace atcoder { namespace internal { // @param n `0 <= n` // @return minimum non-negative `x` s.t. `n <= 2**x` int ceil_pow2(int n) { int x = 0; while ((1U << x) < (unsigned int)(n)) x++; return x; } // @param n `1 <= n` // @return minimum non-negative `x` s.t. `(n & (1 << x)) != 0` constexpr int bsf_constexpr(unsigned int n) { int x = 0; while (!(n & (1 << x))) x++; return x; } // @param n `1 <= n` // @return minimum non-negative `x` s.t. `(n & (1 << x)) != 0` int bsf(unsigned int n) { #ifdef _MSC_VER unsigned long index; _BitScanForward(&index, n); return index; #else return __builtin_ctz(n); #endif } } // namespace internal } // namespace atcoder //line 8 "/home/fujisawa/atcoder/competitive_library/atcoder/lazysegtree.hpp" namespace atcoder { template <class S, S (*_op)(S, S), S (*_e)(), class F, S (*_mapping)(F, S), F (*_composition)(F, F), F (*_id)()> struct lazy_segtree { public: S (*op)(S, S) = _op; S (*e)() = _e; S (*mapping)(F, S) = _mapping; F (*composition)(F, F) = _composition; F (*id)() = _id; lazy_segtree() : lazy_segtree(0) {} explicit lazy_segtree(int n) : lazy_segtree(std::vector<S>(n, _e())) {} explicit lazy_segtree(const std::vector<S>& v) : _n(int(v.size())) { log = internal::ceil_pow2(_n); size = 1 << log; d = std::vector<S>(2 * size, e()); lz = std::vector<F>(size, id()); for (int i = 0; i < _n; i++) d[size + i] = v[i]; for (int i = size - 1; i >= 1; i--) { update(i); } } void set(int p, S x) { assert(0 <= p && p < _n); p += size; for (int i = log; i >= 1; i--) push(p >> i); d[p] = x; for (int i = 1; i <= log; i++) update(p >> i); } void add(int p, S x) { assert(0 <= p && p < _n); (*this).set(p, (*this).get(p) + x); } S get(int p) { assert(0 <= p && p < _n); p += size; for (int i = log; i >= 1; i--) push(p >> i); return d[p]; } S prod(int l, int r) { assert(0 <= l && l <= r && r <= _n); if (l == r) return e(); l += size; r += size; for (int i = log; i >= 1; i--) { if (((l >> i) << i) != l) push(l >> i); if (((r >> i) << i) != r) push((r - 1) >> i); } S sml = e(), smr = e(); while (l < r) { if (l & 1) sml = op(sml, d[l++]); if (r & 1) smr = op(d[--r], smr); l >>= 1; r >>= 1; } return op(sml, smr); } S all_prod() { return d[1]; } void apply(int p, F f) { assert(0 <= p && p < _n); p += size; for (int i = log; i >= 1; i--) push(p >> i); d[p] = mapping(f, d[p]); for (int i = 1; i <= log; i++) update(p >> i); } void apply(int l, int r, F f) { assert(0 <= l && l <= r && r <= _n); if (l == r) return; l += size; r += size; for (int i = log; i >= 1; i--) { if (((l >> i) << i) != l) push(l >> i); if (((r >> i) << i) != r) push((r - 1) >> i); } { int l2 = l, r2 = r; while (l < r) { if (l & 1) all_apply(l++, f); if (r & 1) all_apply(--r, f); l >>= 1; r >>= 1; } l = l2; r = r2; } for (int i = 1; i <= log; i++) { if (((l >> i) << i) != l) update(l >> i); if (((r >> i) << i) != r) update((r - 1) >> i); } } template <bool (*g)(S)> int max_right(int l) { return max_right(l, [](S x) { return g(x); }); } template <class G> int max_right(int l, G g) { assert(0 <= l && l <= _n); assert(g(e())); if (l == _n) return _n; l += size; for (int i = log; i >= 1; i--) push(l >> i); S sm = e(); do { while (l % 2 == 0) l >>= 1; if (!g(op(sm, d[l]))) { while (l < size) { push(l); l = (2 * l); if (g(op(sm, d[l]))) { sm = op(sm, d[l]); l++; } } return l - size; } sm = op(sm, d[l]); l++; } while ((l & -l) != l); return _n; } template <bool (*g)(S)> int min_left(int r) { return min_left(r, [](S x) { return g(x); }); } template <class G> int min_left(int r, G g) { assert(0 <= r && r <= _n); assert(g(e())); if (r == 0) return 0; r += size; for (int i = log; i >= 1; i--) push((r - 1) >> i); S sm = e(); do { r--; while (r > 1 && (r % 2)) r >>= 1; if (!g(op(d[r], sm))) { while (r < size) { push(r); r = (2 * r + 1); if (g(op(d[r], sm))) { sm = op(d[r], sm); r--; } } return r + 1 - size; } sm = op(d[r], sm); } while ((r & -r) != r); return 0; } int n() {return (*this)._n;} private: int _n, size, log; std::vector<S> d; std::vector<F> lz; void update(int k) { d[k] = op(d[2 * k], d[2 * k + 1]); } void all_apply(int k, F f) { d[k] = mapping(f, d[k]); if (k < size) lz[k] = composition(f, lz[k]); } void push(int k) { all_apply(2 * k, lz[k]); all_apply(2 * k + 1, lz[k]); lz[k] = id(); } }; } // namespace atcoder //line 4 "/home/fujisawa/atcoder/competitive_library/competitive/data_structure/lazysegtree.hpp" template <typename S, S (*op)(S, S), S (*e)(), class F, S (*mapping)(F, S), F (*composition)(F, F), F (*id)()> std::ostream& operator<<(std::ostream& os, atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg) { int n = seg.n(); rep(i, n) { os << seg.get(i); if (i != n-1) os << " "; } return os; }; namespace lsegtree_internal { template<typename T> struct AddNode { T value; ll size; AddNode() : value(T(0)), size(1) {}; AddNode(T value, ll size) : value(value), size(size) {}; friend ostream& operator<<(std::ostream& os, const AddNode<T> &n) { os << n.value; return os; }; }; template<typename T> T e_max() { return -INFL; } template<> int e_max() { return -INF; } template<typename T> T e_min() { return INFL; } template<> int e_min() { return INF; } template<typename T> AddNode<T> e_add() { return {0, 1}; } template<typename T> T op_max(T x, T y) { return x > y ? x : y; } template<typename T> T op_min(T x, T y) { return x < y ? x : y; } template<typename T> AddNode<T> op_add(AddNode<T> x, AddNode<T> y) { return {x.value + y.value, x.size + y.size}; } template<typename T> T id_radd(){ return 0; } template<typename T> T id_rupdate(){ return INFL; } template<> int id_rupdate(){ return INF; } template<typename T> AddNode<T> mapping_add_radd(T f, AddNode<T> x){ return {x.value + f * x.size, x.size}; } template<typename T> AddNode<T> mapping_add_rupdate(T f, AddNode<T> x){ AddNode<T> rev = AddNode<T>(x); if(f != id_rupdate<T>()) rev.value = f * rev.size; return rev; } template<typename T> T mapping_radd(T f, T x){ return f+x; } template<typename T> T mapping_rupdate(T f, T x){ return (f == id_rupdate<T>() ? x : f); } template<typename T> T composition_radd(T f, T g){ return f+g; } template<typename T> T composition_rupdate(T f, T g){ return (f == id_rupdate<T>() ? g : f); } } template <typename S, S (*op)(S, S), S (*e)(), class F, S (*mapping)(F, S), F (*composition)(F, F), F (*id)()> using lsegtree = atcoder::lazy_segtree<S, op, e, F, mapping, composition, id>; template<typename T> using lseg_add_radd = atcoder::lazy_segtree<lsegtree_internal::AddNode<T>, lsegtree_internal::op_add<T>, lsegtree_internal::e_add<T>, T, lsegtree_internal::mapping_add_radd<T>, lsegtree_internal::composition_radd<T>, lsegtree_internal::id_radd<T>>; template<typename T> using lseg_min_radd = atcoder::lazy_segtree<T, lsegtree_internal::op_min<T>, lsegtree_internal::e_min<T>, T, lsegtree_internal::mapping_radd<T>, lsegtree_internal::composition_radd<T>, lsegtree_internal::id_radd<T>>; template<typename T> using lseg_max_radd = atcoder::lazy_segtree<T, lsegtree_internal::op_max<T>, lsegtree_internal::e_max<T>, T, lsegtree_internal::mapping_radd<T>, lsegtree_internal::composition_radd<T>, lsegtree_internal::id_radd<T>>; template<typename T> using lseg_add_rupdate = atcoder::lazy_segtree<lsegtree_internal::AddNode<T>, lsegtree_internal::op_add<T>, lsegtree_internal::e_add<T>, T, lsegtree_internal::mapping_add_rupdate<T>, lsegtree_internal::composition_rupdate<T>, lsegtree_internal::id_rupdate<T>>; template<typename T> using lseg_min_rupdate = atcoder::lazy_segtree<T, lsegtree_internal::op_min<T>, lsegtree_internal::e_min<T>, T, lsegtree_internal::mapping_rupdate<T>, lsegtree_internal::composition_rupdate<T>, lsegtree_internal::id_rupdate<T>>; template<typename T> using lseg_max_rupdate = atcoder::lazy_segtree<T, lsegtree_internal::op_max<T>, lsegtree_internal::e_max<T>, T, lsegtree_internal::mapping_rupdate<T>, lsegtree_internal::composition_rupdate<T>, lsegtree_internal::id_rupdate<T>>; /** * @brief 遅延セグメント木(ラッパー) * @docs docs/data_structure/lazysegtree.md */ //line 3 "/home/fujisawa/atcoder/competitive_library/competitive/helper/compress.hpp" template <typename Key, typename Val> struct Compress { vector<Key> coordinates; vector<Val> val; Compress() = default; Compress(const vector<Key> &_coordinates, Val default_val = Val(0)) { coordinates = _coordinates; uniq(coordinates); val = vector<Val>(sz(coordinates), default_val); } int pos(const Key key) const { auto iter = lower_bound(all(coordinates), key); assert(iter != coordinates.end() && *iter == key); return distance(coordinates.begin(), iter); } Val& operator[](Key key) { return val[pos(key)]; } const Val& operator[](const Key key) const { return val[pos(key)]; } Key key_at(const int i) const { return coordinates[i]; } size_t size() const { return coordinates.size(); } }; /** * @brief 座標圧縮 * @docs docs/helper/compress.md */ //line 3 "/home/fujisawa/atcoder/competitive_library/competitive/std/io.hpp" // 演算子オーバーロード(プロトタイプ宣言) template <class T, class U> inline istream& operator>>(istream& is, pair<T, U>& p); template <class T> inline istream& operator>>(istream& is, vector<T>& v); template <class T, class U> inline ostream& operator<<(ostream& os, const pair<T, U>& p); template <class T> inline ostream& operator<<(ostream& os, const vector<T>& v); template <typename T, typename S> ostream &operator<<(ostream &os, const map<T, S> &mp); template <typename T> ostream &operator<<(ostream &os, const set<T> &st); template <typename T> ostream &operator<<(ostream &os, const multiset<T> &st); template <typename T> ostream &operator<<(ostream &os, const unordered_set<T> &st); template <typename T> ostream &operator<<(ostream &os, queue<T> q); template <typename T> ostream &operator<<(ostream &os, deque<T> q); template <typename T> ostream &operator<<(ostream &os, stack<T> st); template <class T, class Container, class Compare> ostream &operator<<(ostream &os, priority_queue<T, Container, Compare> pq); // 演算子オーバーロード template <class T, class U> inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; } template <class T> inline istream& operator>>(istream& is, vector<T>& v) { repe(x, v) is >> x; return is; } template <class T, class U> inline ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.first << " " << p.second; return os; } template <class T> inline ostream& operator<<(ostream& os, const vector<T>& v) { rep(i, sz(v)) { os << v.at(i); if (i != sz(v) - 1) os << " "; } return os; } template <typename T, typename S> ostream &operator<<(ostream &os, const map<T, S> &mp) { for (auto &[key, val] : mp) { os << key << ":" << val << " "; } return os; } template <typename T> ostream &operator<<(ostream &os, const set<T> &st) { auto itr = st.begin(); for (int i = 0; i < (int)st.size(); i++) { os << *itr << (i + 1 != (int)st.size() ? " " : ""); itr++; } return os; } template <typename T> ostream &operator<<(ostream &os, const multiset<T> &st) { auto itr = st.begin(); for (int i = 0; i < (int)st.size(); i++) { os << *itr << (i + 1 != (int)st.size() ? " " : ""); itr++; } return os; } template <typename T> ostream &operator<<(ostream &os, const unordered_set<T> &st) { ll cnt = 0; for (auto &e : st) { os << e << (++cnt != (int)st.size() ? " " : ""); } return os; } template <typename T> ostream &operator<<(ostream &os, queue<T> q) { while (q.size()) { os << q.front() << " "; q.pop(); } return os; } template <typename T> ostream &operator<<(ostream &os, deque<T> q) { while (q.size()) { os << q.front() << " "; q.pop_front(); } return os; } template <typename T> ostream &operator<<(ostream &os, stack<T> st) { while (st.size()) { os << st.top() << " "; st.pop(); } return os; } template <class T, class Container, class Compare> ostream &operator<<(ostream &os, priority_queue<T, Container, Compare> pq) { while (pq.size()) { os << pq.top() << " "; pq.pop(); } return os; } template <typename T> int print_sep_end(string sep, string end, const T& val) { (void)sep; cout << val << end; return 0; }; template <typename T1, typename... T2> int print_sep_end(string sep, string end, const T1 &val, const T2 &...remain) { cout << val << sep; print_sep_end(sep, end, remain...); return 0; }; template <typename... T> int print(const T &...args) { print_sep_end(" ", "\n", args...); return 0; }; template <typename... T> void flush() { cout << flush; }; template <typename... T> int print_and_flush(const T &...args) { print(args...); flush(); return 0; }; #define debug(...) debug_func(0, #__VA_ARGS__, __VA_ARGS__) // debug print template <typename T> void input(T &a) { cin >> a; }; template <typename T1, typename... T2> void input(T1&a, T2 &...b) { cin >> a; input(b...); }; #ifdef LOCAL_TEST template <typename T> void debug_func(int i, const T name) { (void)i; (void)name; cerr << endl; } template <typename T1, typename T2, typename... T3> void debug_func(int i, const T1 &name, const T2 &a, const T3 &...b) { int scope = 0; for ( ; (scope != 0 || name[i] != ',') && name[i] != '\0'; i++ ) { cerr << name[i]; if (name[i] == '(' || name[i] == '{') scope++; if (name[i] == ')' || name[i] == '}') scope--; } cerr << ":" << a << " "; debug_func(i + 1, name, b...); } template <typename T1, typename T2, typename... T3> void debug_func(int i, const T1 &name, T2 &a, T3 &...b) { int scope = 0; for ( ; (scope != 0 || name[i] != ',') && name[i] != '\0'; i++ ) { cerr << name[i]; if (name[i] == '(' || name[i] == '{') scope++; if (name[i] == ')' || name[i] == '}') scope--; } cerr << ":" << a << " "; debug_func(i + 1, name, b...); } #endif #ifndef LOCAL_TEST template <typename... T> void debug_func(T &...) {} template <typename... T> void debug_func(const T &...) {} #endif /** * @brief io.hpp * @docs docs/std/io.md */ //line 100 "answer.cpp" #endif