# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
469996 | rainboy | Deda (COCI17_deda) | C11 | 125 ms | 6716 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |