Submission #426114

# Submission time Handle Problem Language Result Execution time Memory
426114 2021-06-13T14:18:36 Z JeanBombeur Wall (IOI14_wall) C++17
100 / 100
949 ms 62088 KB
#include <iostream>
#include <cstdio>
#include "wall.h"
using namespace std;

const int INFINI = (1000 * 1000 * 1000);
const int TAILLE_ARBRE = (1 << 21);

pair <int, int> Tree[2 * TAILLE_ARBRE];

void Push(int noeud) {
    if (noeud >= TAILLE_ARBRE)
        return;
    for (int d = 0; d < 2; d ++)
    {
        Tree[2 * noeud + d] = {max(Tree[2 * noeud + d].first, Tree[noeud].first), min(Tree[2 * noeud + d].second, Tree[noeud].second)};
        Tree[2 * noeud + d] = {min(Tree[2 * noeud + d].first, Tree[noeud].second), max(Tree[2 * noeud + d].second, Tree[noeud].first)};
    }
    Tree[noeud] = {0, INFINI};
    return;
}

void AddNew(int noeud, int gauche, int droite, int inf, int sup, pair <int, int> update) {
    if (gauche >= sup || droite <= inf)
        return;
    Push(noeud);
    if (inf <= gauche && droite <= sup)
    {
        if (noeud < TAILLE_ARBRE)
            Tree[noeud] = update;
        else
            Tree[noeud].first = Tree[noeud].second = min(max(Tree[noeud].first, update.first), update.second);
        return;
    }
    int mid = (gauche + droite) / 2;
    AddNew(2 * noeud, gauche, mid, inf, sup, update);
    AddNew(2 * noeud + 1, mid, droite, inf, sup, update);
    return;
}

void buildWall(int nbColonnes, int nbOperations, int TypeOp[], int Left[], int Right[], int Hauteur[], int Ans[]){
    
    for (int i = 0; i < nbOperations; i ++)
    {
        if (TypeOp[i] == 1)
            AddNew(1, 0, TAILLE_ARBRE, Left[i], Right[i] + 1, {Hauteur[i], INFINI});
        else
            AddNew(1, 0, TAILLE_ARBRE, Left[i], Right[i] + 1, {0, Hauteur[i]});
    }
    for (int i = 1; i < TAILLE_ARBRE; i ++)
    {
        Push(i);
    }
    for (int i = 0; i < nbColonnes; i ++)
    {
        Ans[i] = Tree[i + TAILLE_ARBRE].first;
    }
    return;
}
# Verdict Execution time Memory Grader output
1 Correct 47 ms 33092 KB Output is correct
2 Correct 48 ms 33192 KB Output is correct
3 Correct 39 ms 33056 KB Output is correct
4 Correct 41 ms 33332 KB Output is correct
5 Correct 45 ms 33244 KB Output is correct
6 Correct 44 ms 33260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 33104 KB Output is correct
2 Correct 375 ms 42384 KB Output is correct
3 Correct 239 ms 38212 KB Output is correct
4 Correct 605 ms 44180 KB Output is correct
5 Correct 393 ms 44992 KB Output is correct
6 Correct 394 ms 44240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 33092 KB Output is correct
2 Correct 40 ms 33152 KB Output is correct
3 Correct 39 ms 33060 KB Output is correct
4 Correct 47 ms 33296 KB Output is correct
5 Correct 42 ms 33348 KB Output is correct
6 Correct 46 ms 33364 KB Output is correct
7 Correct 36 ms 33136 KB Output is correct
8 Correct 391 ms 42648 KB Output is correct
9 Correct 283 ms 38352 KB Output is correct
10 Correct 605 ms 44028 KB Output is correct
11 Correct 405 ms 45176 KB Output is correct
12 Correct 382 ms 44252 KB Output is correct
13 Correct 35 ms 33048 KB Output is correct
14 Correct 366 ms 42592 KB Output is correct
15 Correct 66 ms 34236 KB Output is correct
16 Correct 654 ms 44520 KB Output is correct
17 Correct 408 ms 44000 KB Output is correct
18 Correct 389 ms 44100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 33004 KB Output is correct
2 Correct 40 ms 33192 KB Output is correct
3 Correct 40 ms 33128 KB Output is correct
4 Correct 51 ms 33348 KB Output is correct
5 Correct 42 ms 33332 KB Output is correct
6 Correct 41 ms 33304 KB Output is correct
7 Correct 37 ms 33092 KB Output is correct
8 Correct 389 ms 42584 KB Output is correct
9 Correct 245 ms 38340 KB Output is correct
10 Correct 580 ms 44292 KB Output is correct
11 Correct 403 ms 45208 KB Output is correct
12 Correct 390 ms 44312 KB Output is correct
13 Correct 36 ms 33104 KB Output is correct
14 Correct 359 ms 42692 KB Output is correct
15 Correct 70 ms 34228 KB Output is correct
16 Correct 618 ms 44408 KB Output is correct
17 Correct 386 ms 44100 KB Output is correct
18 Correct 396 ms 44080 KB Output is correct
19 Correct 831 ms 62088 KB Output is correct
20 Correct 806 ms 58512 KB Output is correct
21 Correct 916 ms 61244 KB Output is correct
22 Correct 943 ms 58488 KB Output is correct
23 Correct 886 ms 58728 KB Output is correct
24 Correct 881 ms 58320 KB Output is correct
25 Correct 887 ms 58376 KB Output is correct
26 Correct 949 ms 60924 KB Output is correct
27 Correct 892 ms 60828 KB Output is correct
28 Correct 882 ms 58340 KB Output is correct
29 Correct 810 ms 58336 KB Output is correct
30 Correct 876 ms 58508 KB Output is correct