Submission #1111115

# Submission time Handle Problem Language Result Execution time Memory
1111115 2024-11-11T14:15:28 Z TheGreatAntivirus Wall (IOI14_wall) C++17
Compilation error
0 ms 0 KB
#include "wall.h"
#include <bits/stdc++.h>

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

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);
    }
}

Compilation message

wall.cpp: In member function 'void segment::push(int, int, int)':
wall.cpp:20:17: error: 'sg' was not declared in this scope
   20 |                 sg[2 * v].mx = min(sg[v].mn, max(sg[v].mx, sg[2 * v].mx));
      |                 ^~
wall.cpp:20:46: error: 'max' was not declared in this scope; did you mean 'std::max'?
   20 |                 sg[2 * v].mx = min(sg[v].mn, max(sg[v].mx, sg[2 * v].mx));
      |                                              ^~~
      |                                              std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from wall.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
wall.cpp:20:32: error: 'min' was not declared in this scope; did you mean 'std::min'?
   20 |                 sg[2 * v].mx = min(sg[v].mn, max(sg[v].mx, sg[2 * v].mx));
      |                                ^~~
      |                                std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from wall.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
wall.cpp: In member function 'void segment::upd(int, int, int, int, int, int, int)':
wall.cpp:39:21: error: 'sg' was not declared in this scope
   39 |                     sg[v].mx = max(sg[v].mx, val);
      |                     ^~
wall.cpp:39:32: error: 'max' was not declared in this scope; did you mean 'std::max'?
   39 |                     sg[v].mx = max(sg[v].mx, val);
      |                                ^~~
      |                                std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from wall.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
wall.cpp:44:21: error: 'sg' was not declared in this scope
   44 |                     sg[v].mn = min(sg[v].mn, val);
      |                     ^~
wall.cpp:44:32: error: 'min' was not declared in this scope; did you mean 'std::min'?
   44 |                     sg[v].mn = min(sg[v].mn, val);
      |                                ^~~
      |                                std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from wall.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
wall.cpp: In member function 'query segment::get(int, int, int, int)':
wall.cpp:64:24: error: 'sg' was not declared in this scope
   64 |                 return sg[v];
      |                        ^~
wall.cpp:69:33: error: 'min' was not declared in this scope; did you mean 'std::min'?
   69 |             query res; res.mn = min(lc.mn, rc.mn);
      |                                 ^~~
      |                                 std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from wall.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
wall.cpp:70:22: error: 'max' was not declared in this scope; did you mean 'std::max'?
   70 |             res.mx = max(lc.mx, rc.mx);
      |                      ^~~
      |                      std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from wall.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
wall.cpp: In function 'void buildWall(int, int, int*, int*, int*, int*, int*)':
wall.cpp:80:21: error: 'MAXN' was not declared in this scope
   80 |         s.upd(1, 0, MAXN - 1, left[i], right[i], height[i], op[i]);
      |                     ^~~~
wall.cpp:84:33: error: 'MAXN' was not declared in this scope
   84 |         query ans = s.get(1, 0, MAXN - 1, i);
      |                                 ^~~~
wall.cpp:85:26: error: 'min' was not declared in this scope; did you mean 'std::min'?
   85 |         finalHeight[i] = min(ans.mx, ans.mn);
      |                          ^~~
      |                          std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from wall.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~