Submission #1127399

#TimeUsernameProblemLanguageResultExecution timeMemory
1127399getacDeda (COCI17_deda)C++20
140 / 140
83 ms2888 KiB
//El Parsieto #include<bits/stdc++.h> #define Fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define rep(i, l, r) for(ii i = l; i < r; i++) #define per(i, l, r) for(ii i = r - 1; i >= l; i--) #define min(x, y) (x < 1 ? y : y < 1 ? x : x < y ? x : y) #define pb push_back #define X first #define Y second typedef long long ll; typedef int ii; constexpr ii xn = 4e5 + 5; using namespace std; ii s[xn], e; void upd(ii v, ii l, ii r, ii x, ii y) { if(x < l || r <= x) return; if(r - l < 2) { s[v] = y; return; } ii m = l + r >> 1; ii rc = v + (m - l) * 2; upd(v + 1, l, m, x, y), upd(rc, m, r, x, y); s[v] = min(s[v + 1], s[rc]); } void get(ii v, ii l, ii r, ii x, ii y) { if(r <= x || !s[v] || s[v] > y) return; if(r - l < 2) { e = l + 1; return; } ii m = l + r >> 1; ii rc = v + (m - l) * 2; get(v + 1, l, m, x, y); if(e > 0) return; get(rc, m, r, x, y); } int main() { Fast; ii n, q, x, y; cin >> n >> q; while(q--) { char o; cin >> o >> y >> x; x--; if(o == 'M') upd(0, 0, n, x, y); else { e = -1, get(0, 0, n, x, y); cout << e << '\n'; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...