# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
4862 | tncks0121 | Weighting stones (IZhO11_stones) | C++98 | 85 ms | 5180 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.
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <functional>
#include <vector>
#include <deque>
#include <utility>
#include <bitset>
#include <limits.h>
#include <time.h>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
typedef double lf;
typedef unsigned int uint;
typedef long double llf;
typedef pair<int, int> pii;
const int LEAF = 131072;
const int N_ = 100005;
int N;
struct node {
int sum, tag;
int mn, mx;
} Tree[LEAF+LEAF];
void spread (int nd, int len) {
if(nd < LEAF) {
for(int k = 0; k < 2; k++) {
Tree[nd+nd+k].sum += Tree[nd].tag * (len/2);
Tree[nd+nd+k].mn += Tree[nd].tag;
Tree[nd+nd+k].mx += Tree[nd].tag;
Tree[nd+nd+k].tag += Tree[nd].tag;
}
Tree[nd].tag = 0;
}
}
void update (int nd, int nl, int nr, int x, int y, int d) {
node &u = Tree[nd];
int nmid = (nl + nr) >> 1;
spread(nd, nr-nl+1);
if(x <= nl && nr <= y) {
u.sum += d * (nr-nl+1);
u.mn += d;
u.mx += d;
u.tag += d;
return;
}
if(x <= nmid)
update(nd+nd, nl, nmid, x, min(y, nmid), d);
if(y > nmid)
update(nd+nd+1, nmid+1, nr, max(x, nmid+1), y, d);
Tree[nd].sum = Tree[nd+nd].sum + Tree[nd+nd+1].sum;
Tree[nd].mn = min(Tree[nd+nd].mn, Tree[nd+nd+1].mn);
Tree[nd].mx = max(Tree[nd+nd].mx, Tree[nd+nd+1].mx);
Tree[nd].tag = 0;
}
void update (int p, int d) {
update(1, 1, LEAF, 1, p, d);
}
int main() {
int i, j, k;
scanf("%d", &N);
while(N--) {
int r, s; scanf("%d%d", &r, &s);
int v = (s == 1) ? 1 : -1;
update(r, v);
bool h1 = (Tree[1].mn >= 0);
bool h2 = (Tree[1].mx <= 0);
putchar((h1 ^ h2) ? (h1 ? '>' : '<') : '?');
putchar('\n');
//printf("%d %d %d %d\n", Tree[1].mn, Tree[1].mx, h1, h2);
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |