Submission #239212

# Submission time Handle Problem Language Result Execution time Memory
239212 2020-06-14T20:00:25 Z aggu_01000101 Wall (IOI14_wall) C++14
0 / 100
5 ms 384 KB
#include <bits/stdc++.h>
#include "wall.h"
#define int long long
#define INF 1000000000000000
#define lchild(i) (i*2 + 1)
#define rchild(i) (i*2 + 2)
#define mid(l, u) ((l+u)/2)
#define x(p) p.first
#define y(p) p.second
#define MOD 998244353
using namespace std;
const int N = 2000005;
int seg[4*N];
pair<int, int> lazy[4*N];
int build(int l, int u, int i){
    lazy[i] = {-INF, INF};
    if(l==u) return seg[i] = 0;
    return seg[i] = min(build(l, mid(l, u), lchild(i)), build(mid(l, u)+1, u, rchild(i)));
}
int query(int l, int u, int i, int ll, int uu){
    if(lazy[i].second != INF || lazy[i].first != INF){
        seg[i] = min(seg[i], lazy[i].second);
        seg[i] = max(seg[i], lazy[i].first);
        if(l!=u){
            lazy[lchild(i)].second = min(lazy[lchild(i)].second, lazy[i].second);
            lazy[lchild(i)].first = min(lazy[lchild(i)].first, lazy[i].second);
            lazy[lchild(i)].first = max(lazy[lchild(i)].first, lazy[i].first);
            lazy[lchild(i)].second = max(lazy[lchild(i)].second, lazy[i].first);

            lazy[rchild(i)].second = min(lazy[rchild(i)].second, lazy[i].second);
            lazy[rchild(i)].first = min(lazy[rchild(i)].first, lazy[i].second);
            lazy[rchild(i)].first = max(lazy[rchild(i)].first, lazy[i].first);
            lazy[rchild(i)].second = max(lazy[rchild(i)].second, lazy[i].first);
        }
        lazy[i].second = INF;
        lazy[i].first = -INF;
    }
    if(l>=ll && u<=uu) return seg[i];
    if(l>uu || u<ll) return INF;
    return min(query(l, mid(l, u), lchild(i), ll, uu), query(mid(l, u)+1, u, rchild(i), ll, uu));
}
int update(int l, int u, int i, int ll, int uu, int upval, int type){
    if(lazy[i].second != INF || lazy[i].first != INF){
        seg[i] = min(seg[i], lazy[i].second);
        seg[i] = max(seg[i], lazy[i].first);
        if(l!=u){
            lazy[lchild(i)].second = min(lazy[lchild(i)].second, lazy[i].second);
            lazy[lchild(i)].first = min(lazy[lchild(i)].first, lazy[i].second);
            lazy[lchild(i)].first = max(lazy[lchild(i)].first, lazy[i].first);
            lazy[lchild(i)].second = max(lazy[lchild(i)].second, lazy[i].first);

            lazy[rchild(i)].second = min(lazy[rchild(i)].second, lazy[i].second);
            lazy[rchild(i)].first = min(lazy[rchild(i)].first, lazy[i].second);
            lazy[rchild(i)].first = max(lazy[rchild(i)].first, lazy[i].first);
            lazy[rchild(i)].second = max(lazy[rchild(i)].second, lazy[i].first);
        }
        lazy[i].second = INF;
        lazy[i].first = -INF;
    }
    if(l>=ll && u<=uu){
        if(type==1){
            lazy[i].first = max(lazy[i].first, upval);
        }
        else{
            lazy[i].second = min(lazy[i].second, upval);
        }
        if(lazy[i].second != INF || lazy[i].first != INF){
            seg[i] = min(seg[i], lazy[i].second);
            seg[i] = max(seg[i], lazy[i].first);
            if(l!=u){
                lazy[lchild(i)].second = min(lazy[lchild(i)].second, lazy[i].second);
                lazy[lchild(i)].first = min(lazy[lchild(i)].first, lazy[i].second);
                lazy[lchild(i)].first = max(lazy[lchild(i)].first, lazy[i].first);
                lazy[lchild(i)].second = max(lazy[lchild(i)].second, lazy[i].first);

                lazy[rchild(i)].second = min(lazy[rchild(i)].second, lazy[i].second);
                lazy[rchild(i)].first = min(lazy[rchild(i)].first, lazy[i].second);
                lazy[rchild(i)].first = max(lazy[rchild(i)].first, lazy[i].first);
                lazy[rchild(i)].second = max(lazy[rchild(i)].second, lazy[i].first);
            }
            lazy[i].second = INF;
            lazy[i].first = -INF;
        }
        return seg[i];
    }
    if(l>uu || u<ll) return seg[i];
    return seg[i] = min(update(l, mid(l, u), lchild(i), ll, uu, upval, type), update(mid(l, u)+1, u, rchild(i), ll, uu, upval, type));
}
void buildWall(signed n, signed k, signed op[], signed left[], signed right[], signed height[], signed finalheight[]){
    build(0, n-1, 0);
    for(int i = 0;i<k;i++){
        update(0, n-1, 0, left[i], right[i], op[i], height[i]);
    }
    for(int i = 0;i<n;i++) finalheight[i] = query(0, n-1, 0, i, i);
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -