Submission #236883

#TimeUsernameProblemLanguageResultExecution timeMemory
236883DanShadersDeda (COCI17_deda)C++17
140 / 140
494 ms6924 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; #define all(x) begin(x), end(x) #define x first #define y second typedef long long ll; typedef long double ld; template<typename T> using ordered_set_ = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; template<typename T> using normal_queue = priority_queue<T, vector<T>, greater<T>>; const int MAX_TREE = 1 << 19, MAX_N = 1 << 18, INF = 0x3f3f3f3f; int tre[MAX_TREE]; void build() { fill(tre, tre + MAX_TREE, +INF); } void set_(int i, int x) { i += MAX_N; tre[i] = x; i /= 2; while (i) { tre[i] = min(tre[2 * i], tre[2 * i + 1]); i /= 2; } } int get(int l, int r) { l += MAX_N; r += MAX_N; int res = +INF; while (l <= r) { if (l & 1) res = min(res, tre[l]); if (!(r & 1)) res = min(res, tre[r]); l = (l + 1) / 2; r = (r - 1) / 2; } return res; } signed main() { ios::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; build(); for (int i = 0; i < m; ++i) { char type; cin >> type; if (type == 'M') { int x, a; cin >> x >> a; --a; set_(a, x); } else { int y, b; cin >> y >> b; --b; int lef = b - 1, rig = n; while (rig - lef > 1) { int mid = (lef + rig) / 2; if (get(b, mid) <= y) rig = mid; else lef = mid; } if (rig == n) cout << "-1\n"; else cout << rig + 1 << "\n"; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...