Submission #770633

# Submission time Handle Problem Language Result Execution time Memory
770633 2023-07-01T14:39:36 Z hafo Wall (IOI14_wall) C++14
0 / 100
22 ms 62932 KB
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define pb push_back
#define pa pair<int, int>
#define pall pair<ll, int>
#define fi first
#define se second
#define TASK "test"
#define Size(x) (int) x.size()
#define all(x) x.begin(), x.end()
using namespace std;
 
template<typename T1, typename T2> bool mini (T1 &a, T2 b) {if(a > b) a = b; else return 0; return 1;}
template<typename T1, typename T2> bool maxi (T1 &a, T2 b) {if(a < b) a = b; else return 0; return 1;}
 
const int MOD = 1e9 + 7;
const int LOG = 20;
const int maxn = 2e6 + 7;
const ll oo = 1e9 + 69;
 
int n, k, op[maxn], l[maxn], r[maxn], height[maxn], finalHeight[maxn];
 
struct ST {
    struct node {
        int mx, mn;
    }; 
    
    node st[4 * maxn];
    pa lz[4 * maxn];
 
    void init() {
        for(int id = 1; id <= 4 * n; id++) {
            st[id].mx = -oo;
            st[id].mn = oo;
            lz[id] = {-oo, oo};
        }
    }
 
    void fix(int id, int l, int r) {
        maxi(st[id].mx, lz[id].fi);
        maxi(st[id].mn, lz[id].fi);
        mini(st[id].mx, lz[id].se);
        mini(st[id].mn, lz[id].se);
        if(l != r) {
            maxi(lz[id << 1].fi, lz[id].fi);
            mini(lz[id << 1].se, lz[id].se);
            maxi(lz[id << 1 | 1].fi, lz[id].fi);
            mini(lz[id << 1 | 1].se, lz[id].se);
        }
        lz[id] = {-oo, oo};
    }
 
    void update(int id, int l, int r, int u, int v, int val, int type) {
        fix(id, l, r);
        if(r < u || l > v) return;
        if(u <= l && r <= v) {
            if(type == 1) {
                maxi(lz[id].fi, val);
                maxi(lz[id].se, val);
            } else {
                mini(lz[id].fi, val);
                mini(lz[id].se, val);
            }
            fix(id, l, r);
            return;
        }
        int mid = l + r >> 1;
        update(id << 1, l, mid, u, v, val, type);
        update(id << 1 | 1, mid + 1, r, u, v, val, type);
    }
 
    void get(int id, int l, int r) {
        fix(id, l, r);
        if(l == r) {
            if(st[id].mx == -oo) finalHeight[l - 1] = 0;
            else finalHeight[l - 1] = st[id].mx;
            return;
        }
        int mid = l + r >> 1;
        get(id << 1, l, mid);
        get(id << 1 | 1, mid + 1, r);
    }
} st;
 
void buildWall(int n, int k, int op[], int l[], int r[], int height[], int finalHeight[]) {
     st.init();
    for(int i = 0; i < k; i++) {
        st.update(1, 1, n, l[i] + 1, r[i] + 1, height[i], op[i]);
    }
    st.get(1, 1, n);
}
 

Compilation message

wall.cpp: In member function 'void ST::update(int, int, int, int, int, int, int)':
wall.cpp:68:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   68 |         int mid = l + r >> 1;
      |                   ~~^~~
wall.cpp: In member function 'void ST::get(int, int, int)':
wall.cpp:80:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   80 |         int mid = l + r >> 1;
      |                   ~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 62844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 62852 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 62884 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 62932 KB Output isn't correct
2 Halted 0 ms 0 KB -