結果
問題 | No.3094 Stapler |
ユーザー |
|
提出日時 | 2025-03-03 23:25:00 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 210 ms / 2,000 ms |
コード長 | 2,022 bytes |
コンパイル時間 | 3,686 ms |
コンパイル使用メモリ | 227,868 KB |
実行使用メモリ | 61,320 KB |
最終ジャッジ日時 | 2025-06-20 02:22:13 |
合計ジャッジ時間 | 17,027 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 72 |
ソースコード
#include <bits/stdc++.h> #define rep(i, p, n) for (ll i = p; i < (ll)(n); i++) #define rep2(i, p, n) for (ll i = p; i >= (ll)(n); i--) using namespace std; using ll = long long; using ld = long double; const double pi = 3.141592653589793; const long long inf = 2 * 1e9; const long long linf = 4 * 1e18; const ll mod1 = 1000000007; const ll mod2 = 998244353; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } // atcoder #include <atcoder/all> using namespace atcoder; using mint1 = modint1000000007; using mint2 = modint998244353; vector<pair<ll, ll>> base = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}}; struct S { ll mval, count; }; S op(S a, S b) { if (a.mval < b.mval) { return a; } if (a.mval > b.mval) { return b; } return {a.mval, a.count + b.count}; } S e() { return {inf, 0}; } S mapping(ll f, S a) { return {a.mval + f, a.count}; } ll com(ll f, ll g) { return f + g; } ll id() { return 0; } int main() { ll N, Q; cin >> N >> Q; vector<S> init(N - 1, {0, 1}); vector<pair<ll, ll>> que(Q); lazy_segtree<S, op, e, ll, mapping, com, id> seg(init); rep(i, 0, Q) { ll x; cin >> x; if (x == 1) { ll L, R; cin >> L >> R; L--; R--; seg.apply(L, R, 1); que.at(i) = {L, R}; } else if (x == 2) { ll q; cin >> q; q--; seg.apply(que.at(q).first, que.at(q).second, -1); } else { S temp = seg.prod(0, N - 1); if (temp.mval == 0) { cout << temp.count + 1; } else { cout << 1; } cout << endl; } } }