Submission #719821

# Submission time Handle Problem Language Result Execution time Memory
719821 2023-04-06T18:40:19 Z ovidiush11 Wall (IOI14_wall) C++14
8 / 100
165 ms 35220 KB
#include <bits/stdc++.h>
#include "wall.h"

using namespace std;

#define ff first
#define ss second

const int inf = 1e9;
const int K = 5e5;

int amn[2*K],amx[2*K];
int pos[K];

void build(int p,int l,int r)
{
    if(l == r)pos[l] = p;
    else
    {
        int m = (l + r) / 2;
        build(p*2,l,m);
        build(p*2+1,m+1,r);
    }
    amn[p] = 0;
    amx[p] = inf;
    return ;
}

void change(int p)
{
    if(p == 0)return ;
    int mx = min(amx[p*2],amx[p*2+1]);
    int mn = max(amn[p*2],amn[p*2+1]);
    if(mn > mx)
    {
        if(mn == amn[p*2+1])mx = mn;
        else mn = mx;
    }
    amn[p] = mn;
    amx[p] = mx;
    change(p / 2);
    return ;
}

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[])
{
    queue<int> vq[n+1];
    build(1,0,k-1);
    for(int i = 0;i < k;i++)vq[left[i]].push(i);
    for(int i = 0;i < k;i++)vq[right[i]+1].push(i);
    for(int i = 0;i < n;i++)
    {
        while(!vq[i].empty())
        {
            int v = vq[i].front();
            vq[i].pop();
            if(amn[pos[v]] == 0 && amx[pos[v]] == inf)
            {
                if(op[v] == 1)amn[pos[v]] = height[v];
                else amx[pos[v]] = height[v];
            }
            else
            {
                amn[pos[v]] = 0;
                amx[pos[v]] = inf;
            }
            change(pos[v] / 2);
        }
        finalHeight[i] = amn[1];
    }
    return ;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 10 ms 7372 KB Output is correct
5 Correct 8 ms 7348 KB Output is correct
6 Correct 8 ms 7380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 165 ms 35220 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 8 ms 7252 KB Output is correct
5 Correct 7 ms 7380 KB Output is correct
6 Correct 8 ms 7380 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Runtime error 161 ms 35132 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 3 ms 468 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 9 ms 7320 KB Output is correct
5 Correct 10 ms 7380 KB Output is correct
6 Correct 8 ms 7364 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Runtime error 140 ms 35172 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -