結果
| 問題 |
No.3094 Stapler
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2025-04-06 16:03:03 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 171 ms / 2,000 ms |
| コード長 | 1,041 bytes |
| コンパイル時間 | 3,911 ms |
| コンパイル使用メモリ | 257,720 KB |
| 実行使用メモリ | 32,760 KB |
| 最終ジャッジ日時 | 2025-10-23 22:21:37 |
| 合計ジャッジ時間 | 14,857 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 72 |
ソースコード
#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;
}
沙耶花