Submission #479861

#TimeUsernameProblemLanguageResultExecution timeMemory
479861aris12345678Deda (COCI17_deda)C++14
140 / 140
874 ms4436 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; #define X first #define Y second const int mxN = 200005; const int inf = 1e9+5; int st[4*mxN]; void update(int p, int l, int r, int i, int v) { if(l == r) st[p] = v; else { int md = (l+r)/2; if(i <= md) update(2*p, l, md, i, v); else update(2*p+1, md+1, r, i, v); st[p] = min(st[2*p], st[2*p+1]); } } int Min(int p, int l, int r, int i, int j) { // if(i > r || l > j) // return inf; if(i <= l && r <= j) return st[p]; int md = (l+r)/2; if(j <= md) return Min(2*p, l, md, i, j); if(i > md) return Min(2*p+1, md+1, r, i, j); return min(Min(2*p, l, md, i, j), Min(2*p+1, md+1, r, i, j)); } int main() { int n, q; scanf("%d %d\n", &n, &q); fill(st, st+4*mxN, inf); while(q--) { char type; int l, r; scanf(" %c %d %d", &type, &l, &r); if(type == 'M') update(1, 1, n, r, l); else { int st = r, en = n, md, ans = -1; while(st <= en) { md = (st+en)/2; if(Min(1, 1, n, r, md) <= l) ans = md, en = md-1; else st = md+1; } printf("%d\n", ans); } } return 0; }

Compilation message (stderr)

deda.cpp: In function 'int main()':
deda.cpp:41:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |     scanf("%d %d\n", &n, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
deda.cpp:46:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |         scanf(" %c %d %d", &type, &l, &r);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...