Submission #17446

# Submission time Handle Problem Language Result Execution time Memory
17446 2015-12-12T11:43:07 Z gs14004 Weighting stones (IZhO11_stones) C++14
100 / 100
76 ms 5948 KB
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <functional>
#include <vector>
#include <numeric>
#include <deque>
#include <utility>
#include <bitset>
#include <iostream>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;

struct seg1{
	int tree[270000], lazy[270000];
	void lazydown(int p){
		tree[2*p] += lazy[p];
		tree[2*p+1] += lazy[p];
		lazy[2*p] += lazy[p];
		lazy[2*p+1] += lazy[p];
		lazy[p] = 0;
	}
	void add(int s, int e, int ps, int pe, int p, int v){
		if(e < ps || pe < s) return;
		if(s <= ps && pe <= e){
			tree[p] += v;
			lazy[p] += v;
			return;
		}
		lazydown(p);
		int pm = (ps + pe) / 2;
		add(s, e, ps, pm, 2*p, v);
		add(s, e, pm+1, pe, 2*p+1, v);
		tree[p] = min(tree[2*p], tree[2*p+1]);
	}
}seg1, seg2;

int main(){
    int q;
    scanf("%d",&q);
    for(int i=0; i<q; i++){
        int a, b;
        scanf("%d %d",&b,&a);
        if(a == 1) seg1.add(1, b, 1, q, 1, 1), seg2.add(1, b, 1, q, 1, -1);
        else seg1.add(1, b, 1, q, 1, -1), seg2.add(1, b, 1, q, 1, 1);
        if(seg1.tree[1] >= 0){
        	puts(">");
        }
        else if(seg2.tree[1] >= 0){
        	puts("<");
        }
        else puts("?");
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5948 KB Output is correct - 73 tokens
2 Correct 0 ms 5948 KB Output is correct - 89 tokens
3 Correct 0 ms 5948 KB Output is correct - 221 tokens
4 Correct 0 ms 5948 KB Output is correct - 21 tokens
5 Correct 0 ms 5948 KB Output is correct - 369 tokens
6 Correct 1 ms 5948 KB Output is correct - 492 tokens
7 Correct 0 ms 5948 KB Output is correct - 945 tokens
8 Correct 0 ms 5948 KB Output is correct - 1237 tokens
9 Correct 0 ms 5948 KB Output is correct - 1105 tokens
10 Correct 7 ms 5948 KB Output is correct - 8921 tokens
11 Correct 42 ms 5948 KB Output is correct - 56110 tokens
12 Correct 75 ms 5948 KB Output is correct - 90207 tokens
13 Correct 60 ms 5948 KB Output is correct - 100000 tokens
14 Correct 64 ms 5948 KB Output is correct - 100000 tokens
15 Correct 63 ms 5948 KB Output is correct - 100000 tokens
16 Correct 65 ms 5948 KB Output is correct - 100000 tokens
17 Correct 64 ms 5948 KB Output is correct - 100000 tokens
18 Correct 68 ms 5948 KB Output is correct - 99999 tokens
19 Correct 73 ms 5948 KB Output is correct - 99999 tokens
20 Correct 70 ms 5948 KB Output is correct - 99999 tokens
21 Correct 75 ms 5948 KB Output is correct - 100000 tokens
22 Correct 66 ms 5948 KB Output is correct - 100000 tokens
23 Correct 62 ms 5948 KB Output is correct - 100000 tokens
24 Correct 73 ms 5948 KB Output is correct - 100000 tokens
25 Correct 76 ms 5948 KB Output is correct - 100000 tokens