Submission #676503

#TimeUsernameProblemLanguageResultExecution timeMemory
676503penguin133Deda (COCI17_deda)C++17
140 / 140
176 ms29840 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pi pair<int, int> #define pii pair<int, pair<int, int> > #define fi first #define se second int n,q; struct node{ int s,e,m,val; node *l, *r; node(int _s, int _e){ s = _s, e = _e, m = (s + e)/2, val = 2e9; if(s != e)l = new node(s, m), r= new node(m+1, e); } void upd(int p, int v){ if(s == e)val = v; else{ if(p <= m)l->upd(p, v); else r->upd(p, v); val = min(l->val, r->val); } } int query(int a, int b){ if(a == s && b == e)return val; else if(b <= m)return l->query(a, b); else if(a > m)return r->query(a, b); else return min(l->query(a, m), r->query(m+1, b)); } int find(int a, int v){ if(e < a)return -1; if(s == e)return (val > v ? -1 : s); int x = -1; if(l->val <= v)x = l->find(a, v); if(x != -1)return x; else return r->find(a, v); } }*root; void solve(){ cin >> n >> q; root = new node(1, n); while(q--){ char x;cin >> x; if(x == 'M'){ int a,b;cin >>a >> b; root->upd(b, a); } else{ int a, b;cin >>a >> b; cout << root->find(b, a) << '\n'; } } } main(){ ios::sync_with_stdio(0);cin.tie(0); int t = 1; //cin >> t; while(t--){ solve(); } }

Compilation message (stderr)

deda.cpp:57:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   57 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...