# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
38148 | 14kg | Weighting stones (IZhO11_stones) | C++11 | 63 ms | 7256 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 <stdio.h>
#include <algorithm>
#define min2(x,y) (x<y?x:y)
using namespace std;
int n, nn;
pair<int, int> tree[3][262144];
int cnt[3], MAX[3];
void Update(int x, int y) {
tree[x][y] = { tree[x][y * 2].first + tree[x][y * 2 + 1].first - min2(tree[x][y * 2].first,tree[x][y * 2 + 1].second),
tree[x][y * 2].second + tree[x][y * 2 + 1].second - min2(tree[x][y * 2].first,tree[x][y * 2 + 1].second) };
if (y > 1) Update(x, y / 2);
}
int main() {
int x, w;
scanf("%d", &n);
for (nn = 1; nn < n; nn *= 2);
for (int i = 1; i <= n; i++) {
scanf("%d %d", &x, &w);
cnt[w]++, MAX[w] = MAX[w] > x ? MAX[w] : x;
tree[w][nn + x - 1] = { 0,1 }, Update(w, (nn + x - 1) / 2);
tree[3 - w][nn + x - 1] = { 1,0 }, Update(3 - w, (nn + x - 1) / 2);
if ((cnt[1]<cnt[2] && MAX[1]>MAX[2]) || (cnt[1]>cnt[2] && MAX[1]<MAX[2])) {
printf("?\n");
continue;
}
w = MAX[1] > MAX[2] ? 1 : 2;
if (tree[w][1].first) printf("?\n");
else printf("%c\n", w == 1 ? '>' : '<');
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |