# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
646158 | Hacv16 | Deda (COCI17_deda) | C++17 | 99 ms | 10988 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define sc second
#define fr first
#define all(x) x.begin(), x.end()
#define sz(x) (ll) x.size()
#define dbg(x) cerr << #x << ": [ " << x << " ]\n"
typedef long long ll;
typedef pair<int, int> pii;
const int MAX = 2e5 + 15;
const int INF = 0x3f3f3f3f;
ll n, q, seg[4 * MAX];
void update(ll i, ll x, ll p, ll l, ll r){
if(i > r || i < l) return;
if(l == r){
seg[p] = x;
return;
}
ll m = (l + r) >> 1, e = 2 * p, d = e + 1;
update(i, x, e, l, m);
update(i, x, d, m + 1, r);
seg[p] = min(seg[e], seg[d]);
}
ll bbin(ll i, ll x, ll p, ll l, ll r){
if(seg[p] > x) return -1;
if(l == r) return l;
ll m = (l + r) >> 1, e = 2 * p, d = e + 1;
if(i > m) return bbin(i, x, d, m + 1, r);
ll esq = bbin(i, x, e, l, m);
if(esq == -1) return bbin(i, x, d, m + 1, r);
return esq;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> q;
memset(seg, INF, sizeof(seg));
while(q--){
char op; cin >> op;
if(op == 'M'){
ll x, a; cin >> x >> a;
update(a, x, 1, 1, n);
}else{
ll y, b; cin >> y >> b;
cout << bbin(b, y, 1, 1, n) << '\n';
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |