Submission #826317

#TimeUsernameProblemLanguageResultExecution timeMemory
82631712345678Deda (COCI17_deda)C++17
140 / 140
81 ms7892 KiB
#include <bits/stdc++.h> using namespace std; const int nx=2e5+5; int n, q, x, y; char opr; struct segtree { int d[4*nx]; void update(int l, int r, int i, int idx, int val) { if (idx<l||r<idx) return; if (l==r) return void(d[i]=val); int md=(l+r)/2; update(l, md, 2*i, idx, val); update(md+1, r, 2*i+1, idx, val); d[i]=min(d[2*i], d[2*i+1]); } int query(int l, int r, int i, int B, int Y) { if (r<B||d[i]>Y) return -1; if (l==r) return l; int md=(l+r)/2, lf=query(l, md, 2*i, B, Y); if (lf!=-1) return lf; return query(md+1, r, 2*i+1, B, Y); } } s; int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n>>q; for (int i=0; i<4*nx; i++) s.d[i]=1e9+5; while (q--) { cin>>opr>>x>>y; if (opr=='M') s.update(1, n, 1, y, x); else cout<<s.query(1, n, 1, y, x)<<'\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...