Submission #238818

# Submission time Handle Problem Language Result Execution time Memory
238818 2020-06-13T05:17:47 Z Autoratch Wall (IOI14_wall) C++14
0 / 100
195 ms 14072 KB
#include "wall.h"
#include <bits/stdc++.h>
using namespace std;

const int N = 1 << 11;

int val[N << 1],mn[N << 1],mx[N << 1];
int an[N];

void pushlz(int l,int r,int idx)
{
    if(l==r) val[idx] = max(val[idx],mn[idx]),val[idx] = min(val[idx],mx[idx]);
    else
    {
        mn[idx*2] = max(mn[idx*2],mn[idx]),mx[idx*2] = max(mx[idx*2],mn[idx]);
        mn[idx*2+1] = max(mn[idx*2+1],mn[idx]),mx[idx*2+1] = max(mx[idx*2+1],mn[idx]);
        mx[idx*2] = min(mx[idx*2],mx[idx]),mn[idx*2] = min(mn[idx*2],mx[idx]);
        mx[idx*2+1] = min(mx[idx*2+1],mx[idx]),mn[idx*2+1] = min(mn[idx*2+1],mx[idx]);
    }
    mn[idx] = INT_MIN,mx[idx] = INT_MAX;
}

void build(int l,int r,int idx)
{
    mn[idx] = INT_MIN,mx[idx] = INT_MAX;
    if(l==r) return;
    int m = (l+r)/2;
    build(l,m,idx*2),build(m+1,r,idx*2+1);
}

void update(int l,int r,int idx,int t,int x,int y,int k)
{
    pushlz(l,r,idx);
    if(x>r or y<l) return;
    if(x<=l and y>=r)
    {
        if(t==1) mn[idx] = k;
        else mx[idx] = k;
        pushlz(l,r,idx);
        return;
    }
    int m = (l+r)/2;
    update(l,m,idx*2,t,x,y,k),update(m+1,r,idx*2+1,t,x,y,k);
}

void push(int l,int r,int idx)
{
    pushlz(l,r,idx);
    if(l==r) return void(an[l] = val[idx]);
    int m = (l+r)/2;
    push(l,m,idx*2),push(m+1,r,idx*2+1);
}

void buildWall(int n,int k,int o[],int l[],int r[],int h[],int ans[])
{   
    for(int i = 0;i < k;i++) update(0,n-1,1,o[i],l[i],r[i],h[i]);
    push(0,n-1,1);
    for(int i = 0;i < n;i++) ans[i] = an[i];
}

# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 512 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Runtime error 8 ms 896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 195 ms 14072 KB Output is correct
3 Runtime error 101 ms 11000 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 7 ms 512 KB Output is correct
3 Correct 7 ms 384 KB Output is correct
4 Runtime error 7 ms 896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 7 ms 512 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Runtime error 7 ms 896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Halted 0 ms 0 KB -