Submission #219217

# Submission time Handle Problem Language Result Execution time Memory
219217 2020-04-04T15:47:59 Z summitwei Wall (IOI14_wall) C++17
100 / 100
942 ms 177800 KB
#include <bits/stdc++.h>
#include <wall.h>
using namespace std;
typedef vector<int> vi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 1000000009LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (ll i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (ll i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (ll i=(a); i >= b; i--)

#define MN 2000005
struct Node{
    int l, r;
    int lzl, lzr;
    Node() : l(-INF), r(INF), lzl(-INF), lzr(INF) {}
};
void push(Node *a, int lr, int rr){
    if(a->l < lr) a->l = lr;
    if(a->l > rr) a->l = rr;
    if(a->r < lr) a->r = lr;
    if(a->r > rr) a->r = rr;
}
void add(Node *a, int lr, int rr){
    if(a->lzl < lr) a->lzl = lr;
    if(a->lzl > rr) a->lzl = rr;
    if(a->lzr < lr) a->lzr = lr;
    if(a->lzr > rr) a->lzr = rr;
}
Node tree[4*MN];
void upd(int node, int a, int b, int i, int j, int l, int r){
    if(a > j || b < i) return;
    if(i <= a && b <= j){
        add(tree+node, l, r);
        return;
    }
    push(tree+node, tree[node].lzl, tree[node].lzr);
    if(a != b){
        add(tree+node*2, tree[node].lzl, tree[node].lzr);
        add(tree+node*2+1, tree[node].lzl, tree[node].lzr);
    }
    tree[node].lzl = -INF; tree[node].lzr = INF;
    upd(node*2, a, (a+b)/2, i, j, l, r);
    upd(node*2+1, 1+(a+b)/2, b, i, j, l, r);
}
pii ans[MN];
void fin(int node, int a, int b){
    push(tree+node, tree[node].lzl, tree[node].lzr);
    if(a != b){
        add(tree+node*2, tree[node].lzl, tree[node].lzr);
        add(tree+node*2+1, tree[node].lzl, tree[node].lzr);
    } else{
        ans[a] = {tree[node].l, tree[node].r};
        return;
    }
    fin(node*2, a, (a+b)/2);
    fin(node*2+1, 1+(a+b)/2, b);
}
void pr(int node, int a, int b){
    cout << node << " " << a << " " << b << " " << tree[node].l << " " << tree[node].r << " " << tree[node].lzl << " " << tree[node].lzr << "\n";
    if(a != b){pr(node*2, a, (a+b)/2); pr(node*2+1, 1+(a+b)/2, b);}
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
    F0R(i, k){
        if(op[i] == 1){
            upd(1, 1, n, left[i]+1, right[i]+1, height[i], INF);
        } else{
            upd(1, 1, n, left[i]+1, right[i]+1, -INF, height[i]);
        }
        //pr(1, 1, n);
        //cout << "\n\n";
    }
    fin(1, 1, n);
    F0R(i, n){
        finalHeight[i] = max(0, ans[i+1].f);
    }
}

/*int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, k;
    cin >> n >> k;
    int op[k], left[k], right[k], height[k], finalHeight[n];
    F0R(i, k) cin >> op[i] >> left[i] >> right[i] >> height[i];
    buildWall(n, k, op, left, right, height, finalHeight);
    F0R(i, n) cout << finalHeight[i] << " ";
    cout << "\n";
    
    return 0;
}*/
# Verdict Execution time Memory Grader output
1 Correct 70 ms 125560 KB Output is correct
2 Correct 77 ms 125688 KB Output is correct
3 Correct 77 ms 125560 KB Output is correct
4 Correct 81 ms 125944 KB Output is correct
5 Correct 78 ms 125936 KB Output is correct
6 Correct 77 ms 125944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 78 ms 125560 KB Output is correct
2 Correct 257 ms 134092 KB Output is correct
3 Correct 309 ms 129784 KB Output is correct
4 Correct 734 ms 135160 KB Output is correct
5 Correct 447 ms 145528 KB Output is correct
6 Correct 429 ms 143864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 72 ms 125560 KB Output is correct
2 Correct 72 ms 125688 KB Output is correct
3 Correct 73 ms 125560 KB Output is correct
4 Correct 76 ms 125944 KB Output is correct
5 Correct 75 ms 125940 KB Output is correct
6 Correct 78 ms 125944 KB Output is correct
7 Correct 72 ms 125560 KB Output is correct
8 Correct 241 ms 134112 KB Output is correct
9 Correct 310 ms 129784 KB Output is correct
10 Correct 743 ms 135160 KB Output is correct
11 Correct 449 ms 145528 KB Output is correct
12 Correct 429 ms 143864 KB Output is correct
13 Correct 72 ms 125560 KB Output is correct
14 Correct 251 ms 139184 KB Output is correct
15 Correct 111 ms 126968 KB Output is correct
16 Correct 806 ms 144652 KB Output is correct
17 Correct 450 ms 144120 KB Output is correct
18 Correct 434 ms 144116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 80 ms 125816 KB Output is correct
2 Correct 74 ms 125688 KB Output is correct
3 Correct 76 ms 125612 KB Output is correct
4 Correct 76 ms 125944 KB Output is correct
5 Correct 75 ms 125948 KB Output is correct
6 Correct 76 ms 125944 KB Output is correct
7 Correct 70 ms 125564 KB Output is correct
8 Correct 244 ms 134904 KB Output is correct
9 Correct 306 ms 130552 KB Output is correct
10 Correct 737 ms 136056 KB Output is correct
11 Correct 445 ms 145528 KB Output is correct
12 Correct 425 ms 143864 KB Output is correct
13 Correct 70 ms 125560 KB Output is correct
14 Correct 249 ms 139256 KB Output is correct
15 Correct 109 ms 126968 KB Output is correct
16 Correct 813 ms 144720 KB Output is correct
17 Correct 454 ms 144252 KB Output is correct
18 Correct 434 ms 144120 KB Output is correct
19 Correct 899 ms 177780 KB Output is correct
20 Correct 896 ms 175220 KB Output is correct
21 Correct 896 ms 177800 KB Output is correct
22 Correct 899 ms 175092 KB Output is correct
23 Correct 903 ms 175096 KB Output is correct
24 Correct 891 ms 175236 KB Output is correct
25 Correct 897 ms 175224 KB Output is correct
26 Correct 904 ms 177588 KB Output is correct
27 Correct 929 ms 177644 KB Output is correct
28 Correct 942 ms 175096 KB Output is correct
29 Correct 895 ms 175220 KB Output is correct
30 Correct 905 ms 175212 KB Output is correct