結果

問題 No.3094 Stapler
ユーザー Jinapetto
提出日時 2025-04-06 17:42:22
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 2,207 bytes
コンパイル時間 5,970 ms
コンパイル使用メモリ 333,908 KB
実行使用メモリ 31,580 KB
最終ジャッジ日時 2025-06-20 02:31:49
合計ジャッジ時間 10,961 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 72
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;

//多倍長整数//
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//using bint = mp::cpp_int;

const int INF = 1e9;
const int MOD = 998244353;
const long long LINF = 4e18;

using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vvvvi = vector<vector<vector<vector<int>>>>;
using vvl = vector<vector<long long>>;
using vvvl = vector<vector<vector<long long>>>;
using vvvvl = vector<vector<vector<vector<long long>>>>;
using vvc = vector<vector<char>>;
using vvb = vector<vector<bool>>;
using vvvb = vector<vector<vector<bool>>>;
using vvvvb = vector<vector<vector<vector<bool>>>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ALL(obj) (obj).begin(),(obj).end()

struct dat{
    int mn;
    int cnt;
};

dat op(dat a, dat b){
    if(a.mn == b.mn) return {a.mn, a.cnt + b.cnt};
    else if(a.mn < b.mn) return a;
    else return b;
}

dat e(){
    return {INF, 0};
}

dat mp(int f, dat x){
    return {x.mn + f, x.cnt};
}

int cp(int f,int g){return f + g;}

int id(){return 0;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,q;
    cin >> n >> q;
    dat init;
    init = {0, 1};
    lazy_segtree<dat, op, e, int, mp, cp, id> seg(vector<dat>(n, init));
    vi l(q), r(q);
    rep(i, q){
        int t;
        cin >> t;
        // rep(i,n) cout << seg.get(i).mn << ' ';
        // cout << endl;
        if(t == 1){
            cin >> l[i] >> r[i];
            l[i]--, r[i]--;
            seg.apply(l[i], r[i], 1);
        }else if(t == 2){
            int j;
            cin >> j;
            j--;
            seg.apply(l[j], r[j], -1);
        }else{
            dat ret = seg.all_prod();
            if(ret.mn == 0) cout << ret.cnt << '\n';
            else cout << 1 << '\n';
        }
    }
    return 0;
}
0