Submission #778793

# Submission time Handle Problem Language Result Execution time Memory
778793 2023-07-10T17:04:06 Z Trumling Wall (IOI14_wall) C++14
0 / 100
128 ms 13876 KB
#include "wall.h"
#include <bits/stdc++.h>
using namespace std; 

typedef long long ll;
#define pb push_back
#define F first
#define S second
#define enter cout<<'\n';
#define INF 99999999999999999
#define MOD 1000000007
#define all(x) x.begin(),x.end()

ll laz[8000000];
ll seg[8000000];
ll ans[3000000];

void lazy(int idx)
{
  if(laz[idx]<0)
  {
    if(((laz[idx*2]<0)?-laz[idx*2]:laz[idx*2])>-laz[idx])
    {
      laz[idx*2]=laz[idx];
      seg[idx*2]=-laz[idx];
    }

    if(((laz[idx*2+1]<0)?-laz[idx*2+1]:laz[idx*2+1])>-laz[idx])
    {
      laz[idx*2]=laz[idx];
      seg[idx*2]=-laz[idx];
    }
    return ;
  }

    if(((laz[idx*2]<0)?-laz[idx*2]:laz[idx*2])>laz[idx])
    {
      laz[idx*2]=laz[idx];
      seg[idx*2]=laz[idx];
    }

    if(((laz[idx*2+1]<0)?-laz[idx*2+1]:laz[idx*2+1])>laz[idx])
    {
      laz[idx*2]=laz[idx];
      seg[idx*2]=laz[idx];
    }
}

void build(int l,int r,int idx)
{
  laz[idx]=-1;
  if(l==r)
  return ;

  build(l,(l+r)/2,idx*2);
  build((l+r)/2+1,r,idx*2+1);
}

void up(int l,int r,int idx,int u,int L,int R)
{
  if(r<L || l>R)
  return ;
  if(L<=l && r<=R)
  {
    if(u<0 && seg[idx]>-u)
    { 
    seg[idx]=-u;
    laz[idx]=u;
    }

    if(u>0 && seg[idx]<u)
    {
    seg[idx]=u;
    laz[idx]=u;
    }
    return ;
  }
  lazy(idx);
  up(l,(l+r)/2,idx*2,u,L,R);
  up((l+r)/2+1,r,idx*2+1,u,L,R);
}

void fin(int l,int r,int idx)
{
  if(l==r)
  {
    ans[l]=seg[idx];
    return;
  }
  lazy(idx);
  fin(l,(l+r)/2,idx*2);
  fin((l+r)/2+1,r,idx*2+1);
}

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[])
{
  build(0,n-1,1);
  for(int i=0;i<k;i++)
  up(0,n-1,1,((op[i]==1)?height[i]:-height[i]),left[i],right[i]);

  fin(0,n-1,1);
  for(int i=0;i<n;i++)
  finalHeight[i]=ans[i];

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 448 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 100 ms 13876 KB Output is correct
3 Incorrect 128 ms 8628 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 448 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -