Submission #403325

#TimeUsernameProblemLanguageResultExecution timeMemory
403325penguinhackerDeda (COCI17_deda)C++14
140 / 140
119 ms7872 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ar array const int mxN=2e5; int n, q, st[4*mxN]; void upd(int i, int x, int u=1, int l=0, int r=n-1) { if (l>i||r<i) return; if (l==r) { st[u]=x; return; } int mid=(l+r)/2; upd(i, x, 2*u, l, mid); upd(i, x, 2*u+1, mid+1, r); st[u]=min(st[2*u], st[2*u+1]); } int qry(int ql, int qr, int x, int u=1, int l=0, int r=n-1) { if (l>qr||r<ql||st[u]>x) return -1; if (l==r) return l+1; int mid=(l+r)/2; int al=qry(ql, qr, x, 2*u, l, mid); if (al^-1) return al; return qry(ql, qr, x, 2*u+1, mid+1, r); } int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> q; memset(st, 0x3f, 4*4*n); while(q--) { char t; int a, b; cin >> t >> a >> b; if (t=='M') { upd(b-1, a); } else { cout << qry(b-1, n-1, a) << "\n"; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...