Submission #1245484

#TimeUsernameProblemLanguageResultExecution timeMemory
1245484nlsosadMonkey and Apple-trees (IZhO12_apple)C++20
0 / 100
2095 ms81500 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; // #define int long long using namespace std; struct dynamicsegtreefake{ map<int, int> tr; void update(int node, int start, int end, int l, int r){ // propa(node, start, end); if(start > r or end < l){ return; } if(l<=start and end<=r){ // cout << node << ' ' << start << ' ' << end << " NGU\n"; tr[node] = (end-start+1); // cout << tr[node] << '\n'; return; } int mid = (start+end)/2; update(2*node, start, mid, l, r); update(2*node+1, mid+1, end, l, r); if(tr[node]==(end-start+1)){ return; }else tr[node] = 0; if(node==134217728){ // cout << "YES\n"; // cout << tr[node] << ' ' << tr[2*node] } if(tr.find(2*node)!=tr.end())tr[node] += tr[2*node]; if(tr.find(2*node+1)!=tr.end())tr[node] += tr[2*node+1]; if(node==134217728){ // cout << tr[node] << '\n'; } } int query(int node, int start, int end, int l, int r, int tag){ // propa(node, start, end); if(start > r or end < l){ return 0; } if(tr[node]==(end-start+1))tag = 1; if(l<=start and end<=r){ if(node==134217728){ // cout << tr[node] << " DCMM\n"; } // cout << node << ' ' << start << ' ' << end << " LON\n"; if(tag==1)return (end-start+1); else return tr[node]; } int mid = (start+end)/2; return query(2*node, start, mid, l, r, tag) + query(2*node+1, mid+1, end, l, r, tag); } }; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); int m; cin >> m; int c = 0; dynamicsegtreefake st; while(m--){ int d, x, y; cin >> d >> x >> y; x += c, y += c; if(d==2){ st.update(1, 1, (int)1e9, x, y); }else{ // cout << st.tr[268435457]; // return 0; c = st.query(1, 1, (int)1e9, x, y, 0); cout << c << '\n'; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...