Submission #421244

#TimeUsernameProblemLanguageResultExecution timeMemory
421244OzyWall (IOI14_wall)C++17
8 / 100
388 ms69232 KiB
#include "wall.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define repa(i,a,b) for (int i = (a); i >= (b); i--)
#define lli long long int
#define debugsl(a) cout << #a << " = " << a << ", "
#define debug(a) cout << #a << " = " << a << endl

#define MAX 10000

struct x{
    lli anti;
    lli val;
    lli tipo;

    bool operator < (const x &a)
    const {
        return anti < a.anti;
    }
};

vector<x> inicios[MAX+2],finales[MAX+2];
set<x> activos;

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){

    rep(i,0,k-1) {
        inicios[left[i]].push_back({i,height[i],op[i]});
        finales[right[i]+1].push_back({i,height[i],op[i]});
    }

    rep(i,0,n-1) {

        if (!finales[i].empty()) for (auto e : finales[i]) activos.erase(e);
        if (!inicios[i].empty()) for (auto e : inicios[i]) activos.insert(e);

        for (auto act : activos) {
            if (act.tipo == 1 && finalHeight[i] < act.val) finalHeight[i] = act.val;
            else if (act.tipo == 2 && finalHeight[i] > act.val) finalHeight[i] = act.val;
        }
    }

    return;
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...