답안 #1111117

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1111117 2024-11-11T14:18:19 Z TheGreatAntivirus 벽 (IOI14_wall) C++17
100 / 100
942 ms 69596 KB
#include "wall.h"
#include <bits/stdc++.h>

using namespace std;

const int MAXN = (1 << 21);

struct query
{
    int mx, mn;
    query()
    {
        mx = 0; mn = 1e9;
    }
};

query sg[2 * MAXN];

class segment
{
    public:
        void push(int v, int vl, int vr)
        {
            if(vl != vr)
            {
                sg[2 * v].mx = min(sg[v].mn, max(sg[v].mx, sg[2 * v].mx));
                sg[2 * v + 1].mx = min(sg[v].mn, max(sg[v].mx, sg[2 * v + 1].mx));
                sg[2 * v].mn = max(sg[v].mx, min(sg[v].mn, sg[2 * v].mn));
                sg[2 * v + 1].mn = max(sg[v].mx, min(sg[v].mn, sg[2 * v + 1].mn));
                sg[v].mn = 1e9;
                sg[v].mx = 0;
            }
        }
        void upd(int v, int vl, int vr, int l, int r, int val, int m)
        {
            if(vl > r || vr < l)
            {
                return;
            }
            push(v, vl, vr);
            if(l <= vl && vr <= r)
            {
                if(m == 1)
                {
                    sg[v].mx = max(sg[v].mx, val);
                    sg[v].mn = max(sg[v].mn, sg[v].mx);
                }
                else
                {
                    sg[v].mn = min(sg[v].mn, val);
                    sg[v].mx = min(sg[v].mx, sg[v].mn);
                }
                push(v, vl, vr);
                return;
            }
            int mid = (vl + vr) / 2;
            upd(2 * v, vl, mid, l, r, val, m);
            upd(2 * v + 1, mid + 1, vr, l, r, val, m);
        }
        query get(int v, int vl, int vr, int p)
        {
            if(vl > p || vr < p)
            {
                query tmp;
                return tmp;
            }
            push(v, vl, vr);
            if(vl == vr && vl == p)
            {
                return sg[v];
            }
            int mid = (vl + vr) / 2;
            query lc = get(2 * v, vl, mid, p),
                  rc = get(2 * v + 1, mid + 1, vr, p);
            query res; res.mn = min(lc.mn, rc.mn);
            res.mx = max(lc.mx, rc.mx);
            return res;
        }
};

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[])
{
	segment s;
    for(int i = 0; i < k; i++)
    {
        s.upd(1, 0, MAXN - 1, left[i], right[i], height[i], op[i]);
    }
    for(int i = 0; i < n; i++)
    {
        query ans = s.get(1, 0, MAXN - 1, i);
        finalHeight[i] = min(ans.mx, ans.mn);
    }
}

# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 33104 KB Output is correct
2 Correct 9 ms 33360 KB Output is correct
3 Correct 8 ms 33104 KB Output is correct
4 Correct 14 ms 33360 KB Output is correct
5 Correct 13 ms 33360 KB Output is correct
6 Correct 13 ms 33472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 33104 KB Output is correct
2 Correct 206 ms 46904 KB Output is correct
3 Correct 172 ms 40180 KB Output is correct
4 Correct 441 ms 51216 KB Output is correct
5 Correct 260 ms 52296 KB Output is correct
6 Correct 236 ms 50572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 33104 KB Output is correct
2 Correct 10 ms 33284 KB Output is correct
3 Correct 9 ms 33360 KB Output is correct
4 Correct 13 ms 33360 KB Output is correct
5 Correct 12 ms 33360 KB Output is correct
6 Correct 12 ms 33360 KB Output is correct
7 Correct 7 ms 33104 KB Output is correct
8 Correct 225 ms 46708 KB Output is correct
9 Correct 169 ms 40372 KB Output is correct
10 Correct 422 ms 51272 KB Output is correct
11 Correct 254 ms 52236 KB Output is correct
12 Correct 257 ms 50768 KB Output is correct
13 Correct 7 ms 33104 KB Output is correct
14 Correct 217 ms 46732 KB Output is correct
15 Correct 35 ms 34376 KB Output is correct
16 Correct 468 ms 51528 KB Output is correct
17 Correct 255 ms 50760 KB Output is correct
18 Correct 246 ms 50772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 33272 KB Output is correct
2 Correct 11 ms 33360 KB Output is correct
3 Correct 8 ms 33104 KB Output is correct
4 Correct 15 ms 33360 KB Output is correct
5 Correct 12 ms 33360 KB Output is correct
6 Correct 16 ms 33360 KB Output is correct
7 Correct 11 ms 33104 KB Output is correct
8 Correct 212 ms 46708 KB Output is correct
9 Correct 165 ms 40520 KB Output is correct
10 Correct 424 ms 51212 KB Output is correct
11 Correct 230 ms 52296 KB Output is correct
12 Correct 232 ms 50688 KB Output is correct
13 Correct 7 ms 33104 KB Output is correct
14 Correct 204 ms 46664 KB Output is correct
15 Correct 36 ms 34388 KB Output is correct
16 Correct 474 ms 51460 KB Output is correct
17 Correct 251 ms 50776 KB Output is correct
18 Correct 243 ms 50728 KB Output is correct
19 Correct 942 ms 69480 KB Output is correct
20 Correct 924 ms 67144 KB Output is correct
21 Correct 910 ms 69448 KB Output is correct
22 Correct 877 ms 67144 KB Output is correct
23 Correct 882 ms 67144 KB Output is correct
24 Correct 884 ms 67140 KB Output is correct
25 Correct 918 ms 66884 KB Output is correct
26 Correct 933 ms 69596 KB Output is correct
27 Correct 868 ms 69452 KB Output is correct
28 Correct 812 ms 66888 KB Output is correct
29 Correct 891 ms 67156 KB Output is correct
30 Correct 855 ms 67144 KB Output is correct