Submission #1142311

#TimeUsernameProblemLanguageResultExecution timeMemory
1142311Hamed_GhaffariMonkey and Apple-trees (IZhO12_apple)C++20
100 / 100
26 ms840 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; using pll = pair<long long, long long>; using ull = unsigned long long; #define X first #define Y second #define rep(i,x,y) for(int i=x;i<y;i++) #define repr(i,x,y) for(int i=x;i>y;i--) #define SZ(x) int(x.size()) #define all(x) x.begin(), x.end() #define mins(a,b) (a = min(a,b)) #define maxs(a,b) (a = max(a,b)) #define pb push_back #define Mp make_pair #define mid ((l+r)>>1) mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); const ll INF = 1e9 + 23; const ll MOD = 1e9 + 7; const int MXN = 2e5 + 5; const int LOG = 23; struct node { node *lc, *rc; int ans; node(): lc(NULL), rc(NULL), ans(0) {} }; node *seg; void upd(int s, int e, int l=1, int r=1e9+1, node *v=seg) { if(s>=r || l>=e || v->ans==r-l) return; if(s<=l && r<=e) { v->ans = r-l; return; } if(!v->lc) v->lc = new node(); if(!v->rc) v->rc = new node(); upd(s, e, l, mid, v->lc); upd(s, e, mid, r, v->rc); v->ans = v->lc->ans + v->rc->ans; } int get(int s, int e, int l=1, int r=1e9+1, node *v=seg) { if(s>=r || l>=e || !v->ans) return 0; if(s<=l && r<=e) return v->ans; if(v->ans==r-l) return min(e,r)-max(l,s); return get(s, e, l, mid, v->lc) + get(s, e, mid, r, v->rc); } int c; void Main() { int t, x, y; cin >> t >> x >> y; x += c; y += c+1; if(t==1) cout << (c=get(x, y)) << '\n'; else upd(x, y); } int32_t main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); int T = 1; cin >> T; seg = new node(); while(T--) Main(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...