Submission #1205044

#TimeUsernameProblemLanguageResultExecution timeMemory
1205044PlayVoltzMonkey and Apple-trees (IZhO12_apple)C++20
0 / 100
406 ms327680 KiB
#include <cstdio> #include <stdio.h> #include <stdbool.h> #include <iostream> #include <map> #include <vector> #include <climits> #include <stack> #include <string> #include <queue> #include <algorithm> #include <set> #include <unordered_set> #include <unordered_map> #include <cmath> #include <cctype> #include <bitset> #include <iomanip> #include <cstring> #include <numeric> #include <cassert> using namespace std; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") //#define int long long #define pii pair<int, int> #define mp make_pair #define pb push_back #define fi first #define se second struct node{ int s, e, m, val; bool lazy; node *l, *r; void create(){ if (l==nullptr){ l = new node(s, m); r = new node(m+1, e); } } void propagate(){ if (!lazy)return; val=(e-s+1); if (s!=e){ create(); l->lazy=lazy; r->lazy=lazy; } lazy=0; } node(int S, int E){ s = S, e = E, m = (s+e)/2; val=0; lazy=0; l=r=nullptr; } void up(int left, int right){ propagate(); if (s==left && e==right)lazy=1; else{ create(); if (right<=m)l->up(left, right); else if (left>m)r->up(left, right); else l->up(left, m), r->up(m+1, right); r->propagate(), l->propagate(); val=l->val+r->val; } } int query(int left, int right){ propagate(); if (s==left && e==right)return val; create(); if (right<=m)return l->query(left, right); else if (left>m)return r->query(left, right); else return l->query(left, m)+r->query(m+1, right); } }*st; int32_t main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int q, ans=0, a, b, c; cin>>q; st = new node(1, 1000000005); while (q--){ cin>>a>>b>>c, b+=ans, c+=ans; if (a==1)ans=st->query(b, c), cout<<ans<<"\n"; else st->up(b, c); } }
#Verdict Execution timeMemoryGrader output
Fetching results...