Submission #871998

#TimeUsernameProblemLanguageResultExecution timeMemory
871998vjudge1Deda (COCI17_deda)C++17
100 / 140
127 ms2132 KiB
#include <bits/stdc++.h> using namespace std; const int N = 200'000 + 7, SQ = 450; int n, q, s[N], mn[SQ + 7]; void read_input() { cin >> n >> q; } void pre_process() { fill(s, s + N, 1e9 + 1); fill(mn, mn + SQ + 7, 1e9 + 1); } void change(int x, int a) { s[a] = x; mn[a / SQ] = min(mn[a / SQ], x); } int get(int y, int b) { for (int i = b; i / SQ <= b / SQ; i++) if (s[i] <= y) return i; for (int i = b / SQ + 1; i <= n / SQ; i++) if (mn[i] <= y) { for (int j = i * SQ; j < min((i + 1) * SQ, n + 1); j++) if (s[j] <= y) return j; assert(false); } return -1; } void solve() { while (q--) { char c; int x, y; cin >> c >> x >> y; if (c == 'M') { change(x, y); } else { cout << get(x, y) << '\n'; } } } int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); read_input(); pre_process(); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...