Submission #654850

# Submission time Handle Problem Language Result Execution time Memory
654850 2022-11-01T19:03:23 Z benjaminkleyn Wall (IOI14_wall) C++17
100 / 100
615 ms 69680 KB
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include "wall.h"
using namespace std;
typedef long long ll;

int m[8000000], M[8000000];

void push(int v, int tl, int tr)
{
    if (tl == tr) return;
    m[v*2] = min(m[v*2], m[v]);
    m[v*2] = max(m[v*2], M[v]);

    M[v*2] = min(M[v*2], m[v]);
    M[v*2] = max(M[v*2], M[v]);
    
    m[v*2+1] = min(m[v*2+1], m[v]);
    m[v*2+1] = max(m[v*2+1], M[v]);

    M[v*2+1] = min(M[v*2+1], m[v]);
    M[v*2+1] = max(M[v*2+1], M[v]);
}

void update(int v, int tl, int tr, int l, int r, int val, int op)
{
    push(v, tl, tr);
    if (r < tl || tr < l) return;
    if (l <= tl && tr <= r)
    {
        if (op)
        {
            m[v] = min(m[v], val);
            M[v] = min(M[v], val);
        }
        else
        {
            m[v] = max(m[v], val);
            M[v] = max(M[v], val);
        }
        return;
    }
    m[v] = INT_MAX, M[v] = INT_MIN;
    int tm = (tl + tr) / 2;
    update(v*2, tl, tm, l, r, val, op);
    update(v*2+1, tm+1, tr, l, r, val, op);
}

void fill(int v, int tl, int tr, int res[])
{
    if (tl == tr)
    {
        res[tl] = m[v];
        return;
    }
    push(v, tl, tr);
    int tm = (tl + tr) / 2;
    fill(v*2, tl, tm, res);
    fill(v*2+1, tm+1, tr, res);
}

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

    fill(1, 0, n-1, finalHeight);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 4 ms 724 KB Output is correct
5 Correct 4 ms 828 KB Output is correct
6 Correct 4 ms 832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 135 ms 14032 KB Output is correct
3 Correct 138 ms 7884 KB Output is correct
4 Correct 361 ms 20320 KB Output is correct
5 Correct 272 ms 21420 KB Output is correct
6 Correct 265 ms 19792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 3 ms 448 KB Output is correct
3 Correct 2 ms 316 KB Output is correct
4 Correct 7 ms 724 KB Output is correct
5 Correct 4 ms 828 KB Output is correct
6 Correct 4 ms 724 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 138 ms 13872 KB Output is correct
9 Correct 139 ms 7936 KB Output is correct
10 Correct 392 ms 20320 KB Output is correct
11 Correct 278 ms 21376 KB Output is correct
12 Correct 270 ms 19884 KB Output is correct
13 Correct 1 ms 304 KB Output is correct
14 Correct 133 ms 13964 KB Output is correct
15 Correct 23 ms 2024 KB Output is correct
16 Correct 378 ms 20572 KB Output is correct
17 Correct 267 ms 20024 KB Output is correct
18 Correct 260 ms 20060 KB Output is correct
# 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 Correct 1 ms 340 KB Output is correct
4 Correct 5 ms 724 KB Output is correct
5 Correct 4 ms 724 KB Output is correct
6 Correct 4 ms 724 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 141 ms 13880 KB Output is correct
9 Correct 138 ms 7908 KB Output is correct
10 Correct 395 ms 20400 KB Output is correct
11 Correct 262 ms 21488 KB Output is correct
12 Correct 269 ms 19876 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 137 ms 13840 KB Output is correct
15 Correct 24 ms 1928 KB Output is correct
16 Correct 371 ms 20580 KB Output is correct
17 Correct 278 ms 19988 KB Output is correct
18 Correct 264 ms 20028 KB Output is correct
19 Correct 599 ms 69524 KB Output is correct
20 Correct 595 ms 67036 KB Output is correct
21 Correct 594 ms 69528 KB Output is correct
22 Correct 603 ms 67008 KB Output is correct
23 Correct 596 ms 67280 KB Output is correct
24 Correct 589 ms 67056 KB Output is correct
25 Correct 597 ms 66956 KB Output is correct
26 Correct 615 ms 69524 KB Output is correct
27 Correct 597 ms 69680 KB Output is correct
28 Correct 600 ms 67040 KB Output is correct
29 Correct 602 ms 67160 KB Output is correct
30 Correct 602 ms 67020 KB Output is correct