Submission #469996

#TimeUsernameProblemLanguageResultExecution timeMemory
469996rainboyDeda (COCI17_deda)C11
140 / 140
125 ms6716 KiB
#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)

deda.c: In function 'main':
deda.c:46:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |  scanf("%d%d", &n, &q);
      |  ^~~~~~~~~~~~~~~~~~~~~
deda.c:52:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |   scanf("%s", s);
      |   ^~~~~~~~~~~~~~
deda.c:54:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |    scanf("%d%d", &x, &i), i--;
      |    ^~~~~~~~~~~~~~~~~~~~~
deda.c:57:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |    scanf("%d%d", &x, &i), i--;
      |    ^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...