#include<bits/stdc++.h>
#define pb push_back
#define pf push_front
#define mp make_pair
#define F first
#define S second
#define ff first
#define ss second
#define str string
#define Wansur "gay"
#define ll long long
#define ull unsigned ll
#define ld long double
#define pll pair<ll,ll>
#define plll pair<pll,ll>
#define pllll pair<pll,pll>
#define pii pair<int,int>
#define pld pair<ld,ld>
#define vl vector<ll>
#define vll vector<pll>
#define vlll vector<plll>
#define vllll vector<pllll>
#define vb vector<bool>
#define vi vector<int>
#define vii vector<pii>
#define sz(x) (ll)(x).size()
#define fr front()
#define tp top()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bk back();
#pragma GCC target( "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3")
using namespace std;
const ld pi=acos(-1.0);
const ll e5=1e5;
const ll e6=1e6;
const ll e9=1e9;
const ll inf=1e18;
const ll mod=1e9+7;
const ll mod2=998244353;
const ll MOD=106710087877475399;
const ll N=2e5+10;
const ll M=2e6+10;
const ld eps=1e-9;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll bpm(ll x,ll y,ll m){if(y==0)return 1%m;ll p=bpm(x,y/2,m);
if(y%2==0)return p*p%m;else return p*p%m*x%m;}
ll bp(ll x,ll y){if(y==0)return 1;ll p=bp(x,y/2);
if(y%2==0)return p*p;else return p*p*x;}
ll q;
ll t[N*50],L[N*50],R[N*50], sz=1;
bool ps[N*50];
void push(ll v,ll l,ll r){
if(l<r){
if(!L[v]) L[v]=++sz;
if(!R[v]) R[v]=++sz;
}
if(!ps[v]) return;
t[v]=r-l+1;
if(l<r){
ps[L[v]]=1;
ps[R[v]]=1;
}
ps[v]=0;
}
void upd(ll v,ll l,ll r,ll ql,ll qr){
push(v,l,r);
if(qr<l||r<ql) return;
if(ql<=l&&r<=qr){
ps[v]=1;
push(v,l,r);
return;
}
ll m=(l+r)/2;
upd(L[v],l,m,ql,qr);
upd(R[v],m+1,r,ql,qr);
t[v]=t[L[v]]+t[R[v]];
}
ll get(ll v,ll l,ll r,ll ql,ll qr){
push(v,l,r);
if(qr<l||r<ql) return 0;
if(ql<=l&&r<=qr) return t[v];
ll m=(l+r)/2;
return get(L[v],l,m,ql,qr) + get(R[v],m+1,r,ql,qr);
}
void solve(){
cin>>q;
ll c=0;
while(q--){
ll d,x,y; cin>>d>>x>>y;
if(d==1){
ll s=get(1,1,1e9,x+c,y+c);
cout<<s<<'\n';
c=s;
}else{
upd(1,1,1e9,x+c,y+c);
}
}
}
int main(/*Aldk*/){
ios_base::sync_with_stdio(false); cin.tie(NULL);
// freopen("f.in", "r", stdin);
// freopen("f.out ", "w", stdout);
//cout<<setprecision(6)<<fixed;
int test=1;
// cin>>test;
for(int i=1;i<=test;i++){
solve();
cout<<'\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |