# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
91724 | SamAnd | Weighting stones (IZhO11_stones) | C++17 | 72 ms | 7672 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;
const int N = 100005;
struct ban
{
int l, r;
ban()
{
l = r = 0;
}
ban(int l, int r)
{
this->l = l;
this->r = r;
}
};
int n;
ban t[2][N * 4];
ban mer(ban l, ban r)
{
ban res;
res.l = l.l;
res.r = r.r;
if (l.r + r.l >= 0)
res.l += (l.r + r.l);
else
res.r += (l.r + r.l);
return res;
}
void ubd(int z, int tl, int tr, int x, int y, int pos)
{
if (tl == tr)
{
if (y == 1)
t[z][pos] = ban(1, 0);
else
t[z][pos] = ban(0, -1);
return;
}
int m = (tl + tr) / 2;
if (x <= m)
ubd(z, tl, m, x, y, pos * 2);
else
ubd(z, m + 1, tr, x, y, pos * 2 + 1);
t[z][pos] = mer(t[z][pos * 2], t[z][pos * 2 + 1]);
}
int main()
{
scanf("%d", &n);
for (int i = 1; i <= n; ++i)
{
int x, y;
scanf("%d%d", &x, &y);
if (y == 1)
{
ubd(0, 1, n, x, 1, 1);
ubd(1, 1, n, x, -1, 1);
}
else
{
ubd(0, 1, n, x, -1, 1);
ubd(1, 1, n, x, 1, 1);
}
if (t[0][1].r == 0)
printf(">\n");
else if (t[1][1].r == 0)
printf("<\n");
else
printf("?\n");
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |