# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
876607 | vjudge1 | Deda (COCI17_deda) | C++17 | 747 ms | 4640 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 TOF_io ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define file_io freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define pb push_back
#define Mp make_pair
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int) (x).size()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef unsigned long long int ull;
const long long inf = 2147483647, INF = 1e18;
const int md = 1e9 + 7;
const int lg = 30 + 2;
const int sq = 320;
const int N = 200 * 1000 + 5;
const int MAXN = 1000 * 1000 + 5;
int n;
int q;
int seg[N << 2];
void upd(int id, int s, int e, int l, int r, int x) {
if (r <= s || e <= l) return;
if (l <= s && e <= r) {
seg[id] = x;
return;
}
int mid = (s + e) / 2;
upd(2 * id, s, mid, l, r, x);
upd(2 * id + 1, mid, e, l, r, x);
seg[id] = min(seg[2 * id], seg[2 * id + 1]);
}
int get(int id, int s, int e, int l, int r) {
if (r <= s || e <= l) return inf;
if (l <= s && e <= r) return seg[id];
int mid = (s + e) / 2;
return min(get(2 * id, s, mid, l, r), get(2 * id + 1, mid, e, l, r));
}
int main() {
TOF_io;
cin >> n >> q;
fill(seg, seg + (N << 2), inf);
for (int i = 0, x, a; i < q; i ++) {
char c; cin >> c;
cin >> x >> a;
if (c == 'M') {
upd(1, 0, n, a - 1, a, x);
}
else {
int l = a - 1, r = n;
while (r - l > 1) {
int mid = (l + r) / 2;
if (get(1, 0, n, l, mid) < x + 1) r = mid;
else l = mid;
}
if (get(1, 0, n, l, l + 1) > x) cout << -1 << '\n';
else cout << l + 1 << '\n';
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |