結果

問題 No.3094 Stapler
ユーザー kotatsugame
提出日時 2025-04-06 15:54:28
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 897 bytes
コンパイル時間 866 ms
コンパイル使用メモリ 79,920 KB
実行使用メモリ 32,288 KB
最終ジャッジ日時 2025-06-20 02:29:50
合計ジャッジ時間 7,296 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 72
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cassert>
#include<atcoder/lazysegtree>
using namespace std;
pair<int,int>op(pair<int,int>a,pair<int,int>b)
{
	if(a.first!=b.first)return min(a,b);
	a.second+=b.second;
	return a;
}
pair<int,int>e(){return make_pair((int)1e9,0);}
pair<int,int>mp(int f,pair<int,int>x)
{
	x.first+=f;
	return x;
}
int cmp(int f,int g){return f+g;}
int id(){return 0;}
int L[1<<17],R[1<<17];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;cin>>N;
	vector<pair<int,int> >init(N-1,make_pair(0,1));
	atcoder::lazy_segtree<pair<int,int>,op,e,int,mp,cmp,id>seg(init);
	int Q;cin>>Q;
	for(int q=0;q<Q;q++)
	{
		int o;cin>>o;
		if(o==1)
		{
			cin>>L[q]>>R[q];
			seg.apply(L[q]-1,R[q]-1,1);
		}
		else if(o==2)
		{
			int t;cin>>t;t--;
			seg.apply(L[t]-1,R[t]-1,-1);
		}
		else
		{
			auto t=seg.all_prod();
			if(t.first>0)t.second=0;
			cout<<t.second+1<<"\n";
		}
	}
}
0