Submission #1054413

#TimeUsernameProblemLanguageResultExecution timeMemory
1054413rahidilbayramliDeda (COCI17_deda)C++17
140 / 140
457 ms9144 KiB
#pragma GCC optimize("-O3") #include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> #define ll long long #define ld long double #define vl vector<ll> #define vi vector<int> #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define f first #define s second #define pii pair<int, int> #define pll pair<ll, ll> #define pb push_back #define p_b pop_back using namespace std; using namespace __gnu_pbds; typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); const ll sz = 2e5+5; ll segtree[4*sz]; void build(ll v, ll l, ll r) { if(l == r) segtree[v] = LLONG_MAX; else { ll mid = (l + r) / 2; build(2*v, l, mid); build(2*v+1, mid+1, r); segtree[v] = LLONG_MAX; } } void update(ll v, ll l, ll r, ll idx, ll val) { if(l == r) segtree[v] = val; else { ll mid = (l + r) / 2; if(idx <= mid) update(2*v, l, mid, idx, val); else update(2*v+1, mid+1, r, idx, val); segtree[v] = min(segtree[2*v], segtree[2*v+1]); } } ll findans(ll v, ll l, ll r, ll tl, ll tr) { if(tl > tr) return LLONG_MAX; if(l == tl && r == tr) return segtree[v]; else { ll mid = (l + r) / 2; ll lans = findans(2*v, l, mid, tl, min(mid, tr)); ll rans = findans(2*v+1, mid+1, r, max(mid+1, tl), tr); return min(lans, rans); } } void solve() { ll n, q, i; cin >> n >> q; build(1, 1, n); while(q--) { char c; cin >> c; if(c == 'M') { ll x, a; cin >> x >> a; update(1, 1, n, a, x); } else { ll y, b; cin >> y >> b; ll l = b, r = n, idx = n + 1; while(l <= r) { ll mid = (l + r) / 2; ll minn = findans(1, 1, n, b, mid); if(minn <= y) { idx = min(idx, mid); r = mid - 1; } else l = mid + 1; } if(idx == n + 1) cout << "-1\n"; else cout << idx << "\n"; } } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll tests = 1; //cin >> tests; while(tests--) { solve(); } }

Compilation message (stderr)

deda.cpp: In function 'void solve()':
deda.cpp:65:14: warning: unused variable 'i' [-Wunused-variable]
   65 |     ll n, q, i;
      |              ^
#Verdict Execution timeMemoryGrader output
Fetching results...