# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
82875 | Milki | Deda (COCI17_deda) | C++14 | 228 ms | 17136 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 FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) (int)x.size()
#define pb(x) push_back(x)
typedef long long ll;
typedef pair<int, int> point;
const int INF = 1e9 + 5, MAXN = 2e5 + 5, off = 1 << 18;
struct Tournament{
int t[2 * off];
Tournament(){ REP(i, 2 * off) t[i] = INF;}
void update(int x, int lo, int hi, int a, int b, int val){
if(lo >= b || hi <= a) return;
if(lo >= a && hi <= b) { t[x] = val; return; }
int mid = (lo + hi) >> 1;
update(x * 2, lo, mid, a, b, val);
update(x * 2 + 1, mid, hi, a, b, val);
t[x] = min(t[x * 2], t[x * 2 + 1]);
}
int get(int x, int lo, int hi, int a, int b, int threshold){
if(lo >= b || hi <= a) return INF;
if(lo >= a && hi <= b){
int mid = (lo + hi) >> 1;
if(x >= off) return t[x] <= threshold ? x - off : INF;
else if(t[x * 2] <= threshold) return get(x * 2, lo, mid, a, b, threshold);
else if(t[x * 2 + 1] <= threshold) return get(x * 2 + 1, mid, hi, a, b, threshold);
else return INF;
}
int mid = (lo + hi) >> 1;
int X = get(x * 2, lo, mid, a, b, threshold);
int Y = get(x * 2 + 1, mid, hi, a, b, threshold);
return min(X, Y);
}
}T;
int n, q;
int main(){
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n >> q;
REP(i, q){
char c; int a, b;
cin >> c >> a >> b;
if(c == 'M'){
T.update(1, 0, off, b, b + 1, a);
}
else{
int val = T.get(1, 0, off, b, off, a);
if(val == INF) cout << -1 << "\n";
else cout << val << "\n";
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |