# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
676148 | Trisanu_Das | Deda (COCI17_deda) | C++17 | 59 ms | 2900 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int mxN=2e5;
int n, q, a, b, segtree[1<<19];
char op;
void update(int s, int x, int i=1, int l=0, int r=n-1) {
segtree[i]=min(x, segtree[i]);
if(l==r) return;
int m=(l+r)/2;
if(s<=m) update(s, x, 2*i, l, m);
else update(s, x, 2*i+1, m+1, r);
}
int query(int s, int x, int i=1, int l=0, int r=n-1) {
if(segtree[i]>x) return -2;
if(l==r) return l;
int m=(l+r)/2, e = -2;
if(s<=m) e = query(s, x, 2*i, l, m);
if(r==-2) e = query(s, x, 2*i+1, m+1, r);
return e;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> q;
memset(segtree, 0x3f, sizeof(segtree));
while(q--) {
cin >> op >> a >> b, --b;
if(op=='M') update(b, a);
else cout << query(b, a)+1 << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |