Submission #778844

# Submission time Handle Problem Language Result Execution time Memory
778844 2023-07-10T20:12:48 Z Trumling Wall (IOI14_wall) C++14
0 / 100
149 ms 8268 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]==INF)
  return ;
 
  if(laz[idx]<0)
  {
    if(laz[idx*2]==INF)
    {
      laz[idx*2]=laz[idx];
      seg[idx*2]=-laz[idx]-1;
    }
    else
    if(((laz[idx*2]<0)?-laz[idx*2]:laz[idx*2])>-laz[idx])
    {
      laz[idx*2]=laz[idx];
      seg[idx*2]=-laz[idx]-1;
    }
 
    if(laz[idx*2+1]==INF)
    {
      laz[idx*2+1]=laz[idx];
      seg[idx*2+1]=-laz[idx]-1;
    }
    else
    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]-1;
    }
  }
  else
  {
    if(laz[idx*2]==INF)
    {
      laz[idx*2]=laz[idx];
      seg[idx*2]=laz[idx]-1;
    }
    else
    if(((laz[idx*2]<0)?-laz[idx*2]:laz[idx*2])>laz[idx])
    {
      laz[idx*2]=laz[idx];
      seg[idx*2]=laz[idx]-1;
    }
 
    if(laz[idx*2+1]==INF)
    {
      laz[idx*2+1]=laz[idx];
      seg[idx*2+1]=laz[idx]-1;
    }
    else
    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]-1;
    }
  }
  laz[idx]=INF;
}
 
void build(int l,int r,int idx)
{
  laz[idx]=INF;
  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+1)
    { 
    seg[idx]=-u-1;
    laz[idx]=u;
    }
 
    if(u>0 && seg[idx]<u-1)
    {
    seg[idx]=u-1;
    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]+1:-height[i]-1),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 340 KB Output is correct
3 Incorrect 2 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 149 ms 8268 KB Output isn't correct
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 340 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 340 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -