Submission #336573

# Submission time Handle Problem Language Result Execution time Memory
336573 2020-12-15T19:12:19 Z jovan_b Weighting stones (IZhO11_stones) C++17
100 / 100
73 ms 6636 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

#define pb push_back

struct Segment{
    int val[1000005], open[1000005], closed[1000005];
    Segment(){

    }
    void mrg(int node){
        int g = min(open[node*2], closed[node*2+1]);
        open[node] = open[node*2] + open[node*2+1]- g;
        closed[node] = closed[node*2] + closed[node*2+1] - g;
        val[node] = val[node*2] + val[node*2+1] + g;
    }
    void upd(int node, int l, int r, int x, int g){
        if(l == r){
            if(g == -1) open[node] = 1;
            else closed[node] = 1;
            return;
        }
        int mid = (l+r)/2;
        if(x <= mid) upd(node*2, l, mid, x, g);
        else upd(node*2+1, mid+1, r, x, g);
        mrg(node);
    }
};

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;
    Segment *prvi = new Segment();
    Segment *drugi = new Segment();
    int prvih = 0, drugih = 0;
    for(int i=1; i<=n; i++){
        int a, b;
        cin >> a >> b;
        if(b == 1){
            prvih++;
            prvi->upd(1, 1, n, a, -1);
            drugi->upd(1, 1, n, a, 1);
        }
        else{
            drugih++;
            prvi->upd(1, 1, n, a, 1);
            drugi->upd(1, 1, n, a, -1);
        }
        if(prvi->val[1] == prvih) cout << "<\n";
        else if(drugi->val[1] == drugih) cout << ">\n";
        else cout << "?\n";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 1 ms 492 KB Output is correct
10 Correct 6 ms 1132 KB Output is correct
11 Correct 42 ms 3436 KB Output is correct
12 Correct 73 ms 6380 KB Output is correct
13 Correct 57 ms 6508 KB Output is correct
14 Correct 57 ms 6508 KB Output is correct
15 Correct 58 ms 6528 KB Output is correct
16 Correct 58 ms 6508 KB Output is correct
17 Correct 58 ms 6508 KB Output is correct
18 Correct 59 ms 6508 KB Output is correct
19 Correct 58 ms 6508 KB Output is correct
20 Correct 58 ms 6636 KB Output is correct
21 Correct 58 ms 6508 KB Output is correct
22 Correct 59 ms 6508 KB Output is correct
23 Correct 61 ms 6508 KB Output is correct
24 Correct 70 ms 6508 KB Output is correct
25 Correct 57 ms 6508 KB Output is correct