# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
469996 | rainboy | Deda (COCI17_deda) | C11 | 125 ms | 6716 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <string.h>
#define N 200000
#define N_ (1 << 18)
int min(int a, int b) { return a < b ? a : b; }
int st[N_ * 2], n_;
void build(int n) {
n_ = 1;
while (n_ < n)
n_ <<= 1;
memset(st, 0x3f, n_ * 2 * sizeof *st);
}
void pul(int i) {
st[i] = min(st[i << 1 | 0], st[i << 1 | 1]);
}
void update(int i, int x) {
st[i += n_] = x;
while (i > 1)
pul(i >>= 1);
}
int query(int l, int x) {
int r = n_ - 1;
for (l += n_, r += n_; l <= r; l >>= 1, r >>= 1)
if ((l & 1) == 1) {
if (st[l] <= x) {
while (l < n_)
l = st[l << 1 | 0] <= x ? l << 1 | 0 : l << 1 | 1;
return l - n_ + 1;
}
l++;
}
return -1;
}
int main() {
int n, q;
scanf("%d%d", &n, &q);
build(n);
while (q--) {
static char s[2];
int i, x;
scanf("%s", s);
if (s[0] == 'M') {
scanf("%d%d", &x, &i), i--;
update(i, x);
} else {
scanf("%d%d", &x, &i), i--;
printf("%d\n", query(i, x));
}
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |