# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1092114 | juicy | Weighting stones (IZhO11_stones) | C++17 | 43 ms | 5468 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;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
const int N = 1e5 + 5;
int n;
struct Segtree {
int s[4 * N], lz[4 * N];
Segtree() = default;
void app(int id, int x) {
s[id] += x;
lz[id] += x;
}
void psh(int id) {
if (lz[id]) {
app(id * 2, lz[id]);
app(id * 2 + 1, lz[id]);
lz[id] = 0;
}
}
void upd(int u, int v, int x, int id, int l, int r) {
if (u <= l && r <= v) {
app(id, x);
return;
}
psh(id);
int m = (l + r) / 2;
if (u <= m) {
upd(u, v, x, id * 2, l, m);
}
if (m < v) {
upd(u, v, x, id * 2 + 1, m + 1, r);
}
s[id] = min(s[id * 2], s[id * 2 + 1]);
}
void upd(int u, int v, int x) {
upd(u, v, x, 1, 1, n);
}
} tree[2];
bool win(int s) {
return tree[s].s[1] >= 0;
}
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n;
for (int i = 0; i < n; ++i) {
int r, s; cin >> r >> s; --s;
tree[s].upd(1, r, -1);
tree[s ^ 1].upd(1, r, 1);
cout << (win(0) ? '<' : (win(1) ? '>' : '?')) << "\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |