Submission #1019439

# Submission time Handle Problem Language Result Execution time Memory
1019439 2024-07-10T20:43:18 Z n3rm1n Wall (IOI14_wall) C++17
8 / 100
3000 ms 104648 KB
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAXN = 2e6 + 10;

struct node
{
    int minval, maxval, lazy;
    node()
    {
        minval = 0;
        maxval = 0;
        lazy = -1;
    }
};


node t[MAXN * 4];

void push_lazy(int i, int l, int r)
{
    if(t[i].lazy == -1)return;

        t[i].minval = t[i].lazy;
        t[i].maxval = t[i].lazy;

    if(l != r)
    {
        t[2*i].lazy = t[i].lazy;
        t[2*i+1].lazy = t[i].lazy;
    }
    t[i].lazy = -1;
}

int ql, qr, x;
void upd_minimum(int i, int l, int r)
{
    push_lazy(i, l, r);
    if(ql > r || qr < l)return;

    if(t[i].maxval <= x)return;
    if(ql <= l && r <= qr)
    {
        //if(t[i].maxval <= x)return;
        if(t[i].minval > x)
        {
            t[i].lazy = x;
            push_lazy(i, l, r);
            return;
        }
      // else return;
    }
    if(l == r)return;
    int mid = (l + r)/2;
    upd_minimum(2*i, l, mid);
    upd_minimum(2*i+1, mid+1, r);

    t[i].minval = min(t[2*i].minval, t[2*i+1].minval);
    t[i].maxval = max(t[2*i].maxval, t[2*i+1].maxval);
}

void upd_maximum(int i, int l, int r)
{
    push_lazy(i, l, r);
    if(ql > r || qr < l)return;

    if(t[i].minval > x)return;
    if(ql <= l && r <= qr)
    {

        if(t[i].maxval < x)
        {
            t[i].lazy = x;
            push_lazy(i, l, r);
            return;
        }
       //else return;
    }
    if(l == r)return;
    int mid = (l + r)/2;
    upd_maximum(2*i, l, mid);
    upd_maximum(2*i+1, mid+1, r);

    t[i].minval = min(t[2*i].minval, t[2*i+1].minval);
    t[i].maxval = max(t[2*i].maxval, t[2*i+1].maxval);
}

int h[MAXN];
void build(int i, int l, int r)
{
    push_lazy(i, l, r);
    if(l == r)
    {
        h[l] = t[i].minval;
        return;
    }
    int mid = (l + r)/2;
    build(2*i, l, mid);
    build(2*i+1, mid+1, r);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[])
{
    for (int i = 0; i < k; ++ i)
    {
        ql = left[i] + 1;
        qr = right[i] + 1;
        x = height[i];
        if(op[i] == 1)
            upd_maximum(1, 1, n);
        else upd_minimum(1, 1, n);
    }
    build(1, 1, n);
    for (int i = 1; i <= n; ++ i)
        finalHeight[i-1] = h[i];
    return;
}

# Verdict Execution time Memory Grader output
1 Correct 34 ms 95832 KB Output is correct
2 Correct 36 ms 95928 KB Output is correct
3 Correct 35 ms 95872 KB Output is correct
4 Correct 43 ms 95836 KB Output is correct
5 Correct 38 ms 95828 KB Output is correct
6 Correct 37 ms 96072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 95756 KB Output is correct
2 Correct 111 ms 103760 KB Output is correct
3 Correct 80 ms 99156 KB Output is correct
4 Correct 152 ms 104648 KB Output is correct
5 Execution timed out 3017 ms 103504 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 34 ms 95816 KB Output is correct
2 Correct 35 ms 95824 KB Output is correct
3 Correct 35 ms 95824 KB Output is correct
4 Correct 37 ms 96000 KB Output is correct
5 Correct 37 ms 95824 KB Output is correct
6 Correct 37 ms 96012 KB Output is correct
7 Correct 37 ms 95828 KB Output is correct
8 Correct 130 ms 103504 KB Output is correct
9 Correct 81 ms 99292 KB Output is correct
10 Correct 145 ms 104600 KB Output is correct
11 Execution timed out 3078 ms 103508 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 40 ms 95836 KB Output is correct
2 Correct 44 ms 95784 KB Output is correct
3 Correct 39 ms 95848 KB Output is correct
4 Correct 44 ms 95828 KB Output is correct
5 Correct 45 ms 95968 KB Output is correct
6 Correct 43 ms 95828 KB Output is correct
7 Correct 39 ms 95828 KB Output is correct
8 Correct 125 ms 103504 KB Output is correct
9 Correct 90 ms 99156 KB Output is correct
10 Correct 157 ms 104532 KB Output is correct
11 Execution timed out 3088 ms 103508 KB Time limit exceeded
12 Halted 0 ms 0 KB -