답안 #1062866

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1062866 2024-08-17T11:22:10 Z andrei_iorgulescu 벽 (IOI14_wall) C++14
24 / 100
321 ms 11604 KB
#include <bits/stdc++.h>
#include "wall.h"
#warning That's not FB, that's my FB

using namespace std;

vector<int> lol;

struct node
{
    int mn = 0, mx = 1e9;
};

node aint[8000005];

void prop(int nod, int l, int r)
{
    if (l == r)
        return;
    aint[2 * nod].mx = min(aint[2 * nod].mx, aint[nod].mx);
    aint[2 * nod + 1].mx = min(aint[2 * nod + 1].mx, aint[nod].mx);
    aint[2 * nod].mn = max(aint[2 * nod].mn, aint[nod].mn);
    aint[2 * nod + 1].mn = max(aint[2 * nod + 1].mn, aint[nod].mn);
    if (aint[2 * nod].mn > aint[2 * nod].mx)
    {
        if (aint[nod].mx > aint[2 * nod].mn)
            aint[2 * nod].mx = aint[2 * nod].mn;
        else
            aint[2 * nod].mn = aint[2 * nod].mx;
    }
    if (aint[2 * nod + 1].mn > aint[2 * nod + 1].mx)
    {
        if (aint[nod].mx > aint[2 * nod + 1].mn)
            aint[2 * nod + 1].mx = aint[2 * nod + 1].mn;
        else
            aint[2 * nod + 1].mn = aint[2 * nod + 1].mx;
    }
    aint[nod].mn = 0;
    aint[nod].mx = 1e9;
}

void update(int nod, int l, int r, int st, int dr, int tip, int h)
{
    if (r < st or dr < l)
        return;
    prop(nod,l,r);
    if (st <= l and r <= dr)
    {
        if (tip == 1)
        {
            aint[nod].mn = max(aint[nod].mn,h);
            aint[nod].mx = max(aint[nod].mx,h);
        }
        else
        {
            aint[nod].mn = min(aint[nod].mn,h);
            aint[nod].mx = min(aint[nod].mx,h);
        }
        return;
    }
    int mij = (l + r) / 2;
    update(2 * nod,l,mij,st,dr,tip,h);
    update(2 * nod + 1,mij + 1,r,st,dr,tip,h);
}

void dfs(int nod, int l, int r)
{
    if (l == r)
        lol[l - 1] = aint[nod].mn;
    else
    {
        prop(nod,l,r);
        int mij = (l + r) / 2;
        dfs(2 * nod,l,mij);
        dfs(2 * nod + 1,mij + 1,r);
    }
}

void buildWall (int n, int k, int op[], int left[], int right[], int height[], int finalHeight[])
{
    lol.resize(n);
    for (int i = 0; i < k; i++)
    {
        left[i]++;
        right[i]++;
        update(1,1,n,left[i],right[i],op[i],height[i]);
    }
    dfs(1,1,n);
    for (int i = 0; i < n; i++)
        finalHeight[i] = lol[i];
}

Compilation message

wall.cpp:3:2: warning: #warning That's not FB, that's my FB [-Wcpp]
    3 | #warning That's not FB, that's my FB
      |  ^~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Incorrect 1 ms 344 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 79 ms 8156 KB Output is correct
3 Correct 109 ms 4328 KB Output is correct
4 Correct 321 ms 11080 KB Output is correct
5 Correct 192 ms 11600 KB Output is correct
6 Correct 174 ms 11604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Incorrect 1 ms 344 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Incorrect 1 ms 344 KB Output isn't correct
4 Halted 0 ms 0 KB -