結果

問題 No.3094 Stapler
ユーザー 沙耶花
提出日時 2025-04-06 16:03:03
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 1,041 bytes
コンパイル時間 4,933 ms
コンパイル使用メモリ 255,704 KB
実行使用メモリ 32,732 KB
最終ジャッジ日時 2025-06-20 02:30:35
合計ジャッジ時間 14,223 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 72
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001LL
using P = pair<int,int>;
P op(P a,P b){
	if(a.first != b.first)return min(a,b);
	else return {a.first,a.second+b.second};
}

P e(){
	return {Inf32,0};
}

P mapping(int b,P a){
	return {a.first+b,a.second};
}

int composition(int a,int b){
	return a+b;
}
int id(){
	return 0;
}
int main(){
	
	int N,Q;
	cin>>N>>Q;
	vector<P> a(N-1,{0,1});
	lazy_segtree<P,op,e,int,mapping,composition,id> seg(a);
	vector<int> t(Q),l(Q),r(Q);
	rep(i,Q){
		cin>>t[i];
		if(t[i]==1){
			cin>>l[i]>>r[i];
			l[i]--;
			if(l[i]!=r[i])seg.apply(l[i],r[i]-1,1);
		}
		else if(t[i]==2){
			cin>>l[i];
			l[i]--;
			int ii = l[i];
			if(l[ii]!=r[ii])seg.apply(l[ii],r[ii]-1,-1);
		}
		else{
			auto res = seg.all_prod();
			int ans = 1;
			if(res.first == 0)ans += res.second;
			cout<<ans<<endl;
		}
	}
	return 0;
}
0