#pragma optimize("Bismillahirrahmanirrahim")
//Allahuekber
//ahmet23 orz...
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//YavuzSultanSelimHan
//AbdulhamidHan
#define author tolbi
#include <bits/stdc++.h>
#define endl '\n'
#define vint(x) vector<int> x
#define deci(x) int x;cin>>x;
#define decstr(x) string x;cin>>x;
#define cinarr(x) for (auto &it : x) cin>>it;
#define coutarr(x) for (auto &it : x) cout<<it<<" ";cout<<endl;
#define sortarr(x) sort(x.begin(),x.end())
#define sortrarr(x) sort(x.rbegin(),x.rend())
#define ayahya() chrono::steady_clock().now().time_since_epoch().count()
#define det(x) cout<<"NO\0YES"+x*3<<endl;
#define INF LONG_LONG_MAX
#define rev(x) reverse(x.begin(),x.end());
#define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define tol(bi) (1LL<<((int)(bi)))
const int MOD = 1e9+7;
using namespace std;
struct Node{
int val, lazy, l, r, lnode, rnode;
Node() : val(0),lazy(0),lnode(-1),rnode(-1){}
};
Node segtree[7000000];
int indi = 1;
void ccheck(int node){
if (segtree[node].l<segtree[node].r){
int mid = segtree[node].l+(segtree[node].r-segtree[node].l)/2;
if (segtree[node].lnode==-1){
segtree[node].lnode=indi++;
segtree[segtree[node].lnode].l=segtree[node].l;
segtree[segtree[node].lnode].r=mid;
}
if (segtree[node].rnode==-1){
segtree[node].rnode=indi++;
segtree[segtree[node].rnode].l=mid+1;
segtree[segtree[node].rnode].r=segtree[node].r;
}
}
}
void dallan(int node){
if (segtree[node].lazy==1){
segtree[node].val=(segtree[node].r-segtree[node].l+1);
if (segtree[node].l<segtree[node].r){
ccheck(node);
if (segtree[segtree[node].lnode].lazy==0) segtree[segtree[node].lnode].lazy=1;
if (segtree[segtree[node].rnode].lazy==0) segtree[segtree[node].rnode].lazy=1;
}
segtree[node].lazy=2;
}
}
int query(int tarl, int tarr, int node=0){
dallan(node);
if (segtree[node].l>=tarl && segtree[node].r<=tarr) return segtree[node].val;
if (segtree[node].l>tarr || segtree[node].r<tarl) return 0ll;
ccheck(node);
int lnode = query(tarl, tarr, segtree[node].lnode);
int rnode = query(tarl, tarr, segtree[node].rnode);
return lnode+rnode;
}
void update(int tarl, int tarr, int node=0){
dallan(node);
if (segtree[node].l==tarl && segtree[node].r==tarr){
if (segtree[node].lazy==0) segtree[node].lazy=1;
dallan(node);
return;
}
ccheck(node);
int mid = segtree[node].l+(segtree[node].r-segtree[node].l)/2;
if (tarl>mid) update(tarl, tarr, segtree[node].rnode);
else if (tarr<=mid) update(tarl, tarr, segtree[node].lnode);
else {
update(tarl, mid, segtree[node].lnode);
update(mid + 1, tarr, segtree[node].rnode);
}
dallan(segtree[node].lnode);
dallan(segtree[node].rnode);
segtree[node].val=segtree[segtree[node].lnode].val+segtree[segtree[node].rnode].val;
}
int32_t main(){
ios;
int t=1;
int tno = 0;
if (!t) cin>>t;
while (t-(tno++)){
deci(q);
segtree[0].l=1;
segtree[0].r=1e9;
int c = 0;
while (q--){
deci(ty);deci(a);deci(b);
if (ty==1){
c=query(a+c,b+c);
cout<<c<<endl;
}
else {
update(a+c,b+c);
}
}
}
}
Compilation message
apple.cpp:1: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
1 | #pragma optimize("Bismillahirrahmanirrahim")
|
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
67 ms |
164684 KB |
Output is correct |
2 |
Correct |
71 ms |
164632 KB |
Output is correct |
3 |
Correct |
68 ms |
164664 KB |
Output is correct |
4 |
Correct |
84 ms |
164684 KB |
Output is correct |
5 |
Correct |
76 ms |
164652 KB |
Output is correct |
6 |
Correct |
77 ms |
164664 KB |
Output is correct |
7 |
Correct |
78 ms |
164628 KB |
Output is correct |
8 |
Correct |
160 ms |
164760 KB |
Output is correct |
9 |
Correct |
275 ms |
164996 KB |
Output is correct |
10 |
Correct |
291 ms |
164956 KB |
Output is correct |
11 |
Correct |
320 ms |
165208 KB |
Output is correct |
12 |
Correct |
309 ms |
165052 KB |
Output is correct |
13 |
Correct |
283 ms |
165240 KB |
Output is correct |
14 |
Correct |
270 ms |
165068 KB |
Output is correct |
15 |
Runtime error |
448 ms |
262144 KB |
Execution killed with signal 9 |
16 |
Halted |
0 ms |
0 KB |
- |