Submission #1046270

#TimeUsernameProblemLanguageResultExecution timeMemory
1046270anastasiskolioDeda (COCI17_deda)C++14
20 / 140
74 ms3480 KiB
#include <bits/stdc++.h> using namespace std; #define MAXN 200000 #define INFTY 1000000000 int N, Q, T[4 * MAXN + 1]; void Build(int lo, int hi, int v) { if (lo == hi) { T[v] = INFTY; return; } int mid = (lo + hi) / 2; Build(lo, mid, 2 * v); Build(mid + 1, hi, 2 * v + 1); T[v] = min(T[2 * v], T[2 * v + 1]); } void Update(int lo, int hi, int v, int A, int X) { if (lo == hi) { T[v] = X; return; } int mid = (lo + hi) / 2; if (A <= mid) Update(lo, mid, 2 * v, A, X); else Update(mid + 1, hi, 2 * v + 1, A, X); T[v] = min(T[2 * v], T[2 * v + 1]); } int Query(int lo, int hi, int v, int Y, int B) { if (lo == hi) return T[v] <= Y && lo >= B ? lo : -1; int mid = (lo + hi) / 2; if (T[2 * v] <= Y && mid >= B) { return Query(lo, mid, 2 * v, Y, B); } return Query(mid + 1, hi, 2 * v + 1, Y, B); } int main() { scanf("%d %d", &N, &Q); Build(1, N, 1); while (Q--) { char C; int A, B; scanf(" %c %d %d", &C, &A, &B); if (C == 'M') Update(1, N, 1, B, A); else printf("%d\n", Query(1, N, 1, A, B)); } return 0; }

Compilation message (stderr)

deda.cpp: In function 'int main()':
deda.cpp:43:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |   scanf("%d %d", &N, &Q);
      |   ~~~~~^~~~~~~~~~~~~~~~~
deda.cpp:48:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |     scanf(" %c %d %d", &C, &A, &B);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...