제출 #274921

#제출 시각아이디문제언어결과실행 시간메모리
274921daniel920712벽 (IOI14_wall)C++14
0 / 100
233 ms14040 KiB
#include "wall.h"
#include <algorithm>
#include <iostream>
#include <stdio.h>
using namespace std;
int all[1000005]={0};
struct A
{
    int l,r;
    int nxl,nxr;
    int big;
    int small;
    int which;
    int last;
}Node[4000005];
int now=1;
void build(int l,int r,int here)
{
    Node[here].l=l;
    Node[here].r=r;
    Node[here].small=0;
    Node[here].big=1e9;
    Node[here].last=1;
    if(l==r)
    {
        Node[here].which=all[l];
        return ;
    }
    Node[here].nxl=now++;
    Node[here].nxr=now++;
    build(l,(l+r)/2,Node[here].nxl);
    build((l+r)/2+1,r,Node[here].nxr);
    Node[here].big=max(Node[Node[here].nxl].big,Node[Node[here].nxr].big);
    Node[here].small=min(Node[Node[here].nxl].small,Node[Node[here].nxr].small);
}
void UPD(int here)
{
    Node[Node[here].nxl].big=min(Node[here].big,Node[Node[here].nxl].big);
    Node[Node[here].nxl].small=max(Node[here].small,Node[Node[here].nxl].small);
    Node[Node[here].nxl].last=Node[here].last;

    Node[Node[here].nxr].big=min(Node[here].big,Node[Node[here].nxr].big);
    Node[Node[here].nxr].small=max(Node[here].small,Node[Node[here].nxr].small);
    Node[Node[here].nxr].last=Node[here].last;
}
int Find(int where,int here)
{
    if(where==Node[here].l&&where==Node[here].r)
    {
        if(Node[here].last==1) return Node[here].small;
        return Node[here].big;
    }
    UPD(here);
    if(where<=(Node[here].l+Node[here].r)/2) return Find(where,Node[here].nxl);
    else return Find(where,Node[here].nxr);

}
void cha(int l,int r,int con,int what,int here)
{
    if(Node[here].l==l&&Node[here].r==r)
    {
        Node[here].last=what;
        if(what==1)
        {
            Node[here].small=max(Node[here].small,con);
            if(Node[here].small>Node[here].big) Node[here].big=Node[here].small;
        }
        else
        {
            Node[here].big=min(Node[here].big,con);
            if(Node[here].small>Node[here].big) Node[here].small=Node[here].big;
        }
        return ;
    }
    UPD(here);
    if(r<=(Node[here].l+Node[here].r)/2) cha(l,r,con,what,Node[here].nxl);
    else if(l>(Node[here].l+Node[here].r)/2) cha(l,r,con,what,Node[here].nxr);
    else
    {
        cha(l,(Node[here].l+Node[here].r)/2,con,what,Node[here].nxl);
        cha((Node[here].l+Node[here].r)/2+1,r,con,what,Node[here].nxr);
    }
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[])
{
    int i,j;
    build(0,n-1,0);
    for(i=0;i<k;i++)
    {
        cha(left[i],right[i],height[i],op[i],0);

    }
    for(i=0;i<n;i++) finalHeight[i]=Find(i,0);
    return;
}

컴파일 시 표준 에러 (stderr) 메시지

wall.cpp: In function 'void buildWall(int, int, int*, int*, int*, int*, int*)':
wall.cpp:86:11: warning: unused variable 'j' [-Wunused-variable]
   86 |     int i,j;
      |           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...