제출 #374864

#제출 시각아이디문제언어결과실행 시간메모리
374864Alex_tz307Wall (IOI14_wall)C++17
컴파일 에러
0 ms0 KiB
struct Segtree { int Size; vector<pair<int,int>> tree; vector<pair<bool,int>> lazy_min, lazy_max; void init(int N) { Size = 1; while(Size < N) Size <<= 1; tree.assign((Size << 1) + 1, make_pair(INT_MAX, 0)); lazy_min.assign((Size << 1) + 1, make_pair(false, INT_MAX)); lazy_max.assign((Size << 1) + 1, make_pair(false, 0)); } void propagate(int x, int lx, int rx) { if(lx == rx) return; if(lazy_min[x].first) { tree[x << 1].first = min(tree[x << 1].first, lazy_min[x].second); tree[(x << 1) | 1].first = min(tree[(x << 1) | 1].first, lazy_min[x].second); tree[x << 1].second = min(tree[x << 1].first, tree[x << 1].second); tree[(x << 1) | 1].second = min(tree[(x << 1) | 1].first, tree[(x << 1) | 1].second); lazy_min[x << 1].first = lazy_min[(x << 1) | 1].first = true; lazy_min[x << 1].second = min(lazy_min[x << 1].second, lazy_min[x].second); lazy_min[(x << 1) | 1].second = min(lazy_min[(x << 1) | 1].second, lazy_min[x].second); if(lazy_max[x << 1].first) lazy_max[x << 1].second = min(lazy_min[x << 1].second, lazy_max[x << 1].second); if(lazy_max[(x << 1) | 1].first) lazy_max[(x << 1) | 1].second = min(lazy_min[(x << 1) | 1].second, lazy_max[(x << 1) | 1].second); lazy_min[x] = make_pair(false, INT_MAX); } if(lazy_max[x].first) { tree[x << 1].second = max(tree[x << 1].second, lazy_max[x].second); tree[(x << 1) | 1].second = max(tree[(x << 1) | 1].second, lazy_max[x].second); tree[x << 1].first = max(tree[x << 1].first, tree[x << 1].second); tree[(x << 1) | 1].first = max(tree[(x << 1) | 1].first, tree[(x << 1) | 1].second); lazy_max[x << 1].first = lazy_max[(x << 1) | 1].first = true; lazy_max[x << 1].second = max(lazy_max[x << 1].second, lazy_max[x].second); lazy_max[(x << 1) | 1].second = max(lazy_max[(x << 1) | 1].second, lazy_max[x].second); if(lazy_min[x << 1].first) lazy_min[x << 1].second = max(lazy_min[x << 1].second, lazy_max[x << 1].second); if(lazy_min[(x << 1) | 1].first) lazy_min[(x << 1) | 1].second = max(lazy_min[(x << 1) | 1].second, lazy_max[(x << 1) | 1].second); lazy_max[x] = make_pair(false, 0); } } void maximize(int x, int lx, int rx, int st, int dr, int h) { propagate(x, lx, rx); if(st <= lx && rx <= dr) { tree[x].second = max(tree[x].second, h); tree[x].first = max(tree[x].first, tree[x].second); lazy_max[x].first = true; lazy_max[x].second = max(lazy_max[x].second, h); return; } int mid = (lx + rx) >> 1; if(st <= mid) maximize(x << 1, lx, mid, st, dr, h); if(mid < dr) maximize((x << 1) | 1, mid + 1, rx, st, dr, h); } void minimize(int x, int lx, int rx, int st, int dr, int h) { propagate(x, lx, rx); if(st <= lx && rx <= dr) { tree[x].first = min(tree[x].first, h); tree[x].second = min(tree[x].second, tree[x].first); lazy_min[x].first = true; lazy_min[x].second = min(lazy_min[x].second, h); return; } int mid = (lx + rx) >> 1; if(st <= mid) minimize(x << 1, lx, mid, st, dr, h); if(mid < dr) minimize((x << 1) | 1, mid + 1, rx, st, dr, h); } int query(int x, int lx, int rx, int poz) { propagate(x, lx, rx); if(lx == rx) return tree[x].second; int mid = (lx + rx) >> 1; if(poz <= mid) return query(x << 1, lx, mid, poz); else return query((x << 1) | 1, mid + 1, rx, poz); } }; void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]) { Segtree tree; tree.init(N); for(int i = 0; i < k; ++i) if(op[i] == 1) tree.maximize(1, 1, N, left[i] + 1, right[i] + 1, height[i]); else tree.minimize(1, 1, N, left[i] + 1, right[i] + 1, height[i]); for(int i = 0; i < N; ++i) finalHeight[i] = tree.query(1, 1, N, i + 1) }

컴파일 시 표준 에러 (stderr) 메시지

wall.cpp:3:5: error: 'vector' does not name a type
    3 |     vector<pair<int,int>> tree;
      |     ^~~~~~
wall.cpp:4:5: error: 'vector' does not name a type
    4 |     vector<pair<bool,int>> lazy_min, lazy_max;
      |     ^~~~~~
wall.cpp: In member function 'void Segtree::init(int)':
wall.cpp:10:9: error: 'tree' was not declared in this scope; did you mean 'Segtree'?
   10 |         tree.assign((Size << 1) + 1, make_pair(INT_MAX, 0));
      |         ^~~~
      |         Segtree
wall.cpp:10:48: error: 'INT_MAX' was not declared in this scope
   10 |         tree.assign((Size << 1) + 1, make_pair(INT_MAX, 0));
      |                                                ^~~~~~~
wall.cpp:1:1: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
  +++ |+#include <climits>
    1 | struct Segtree {
wall.cpp:10:38: error: 'make_pair' was not declared in this scope
   10 |         tree.assign((Size << 1) + 1, make_pair(INT_MAX, 0));
      |                                      ^~~~~~~~~
wall.cpp:11:9: error: 'lazy_min' was not declared in this scope
   11 |         lazy_min.assign((Size << 1) + 1, make_pair(false, INT_MAX));
      |         ^~~~~~~~
wall.cpp:12:9: error: 'lazy_max' was not declared in this scope
   12 |         lazy_max.assign((Size << 1) + 1, make_pair(false, 0));
      |         ^~~~~~~~
wall.cpp: In member function 'void Segtree::propagate(int, int, int)':
wall.cpp:18:12: error: 'lazy_min' was not declared in this scope
   18 |         if(lazy_min[x].first) {
      |            ^~~~~~~~
wall.cpp:19:13: error: 'tree' was not declared in this scope; did you mean 'Segtree'?
   19 |             tree[x << 1].first = min(tree[x << 1].first, lazy_min[x].second);
      |             ^~~~
      |             Segtree
wall.cpp:19:34: error: 'min' was not declared in this scope
   19 |             tree[x << 1].first = min(tree[x << 1].first, lazy_min[x].second);
      |                                  ^~~
wall.cpp:26:16: error: 'lazy_max' was not declared in this scope
   26 |             if(lazy_max[x << 1].first)
      |                ^~~~~~~~
wall.cpp:28:16: error: 'lazy_max' was not declared in this scope
   28 |             if(lazy_max[(x << 1) | 1].first)
      |                ^~~~~~~~
wall.cpp:30:44: error: 'INT_MAX' was not declared in this scope
   30 |             lazy_min[x] = make_pair(false, INT_MAX);
      |                                            ^~~~~~~
wall.cpp:30:44: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
wall.cpp:30:27: error: 'make_pair' was not declared in this scope
   30 |             lazy_min[x] = make_pair(false, INT_MAX);
      |                           ^~~~~~~~~
wall.cpp:32:12: error: 'lazy_max' was not declared in this scope
   32 |         if(lazy_max[x].first) {
      |            ^~~~~~~~
wall.cpp:33:13: error: 'tree' was not declared in this scope; did you mean 'Segtree'?
   33 |             tree[x << 1].second = max(tree[x << 1].second, lazy_max[x].second);
      |             ^~~~
      |             Segtree
wall.cpp:33:35: error: 'max' was not declared in this scope
   33 |             tree[x << 1].second = max(tree[x << 1].second, lazy_max[x].second);
      |                                   ^~~
wall.cpp:40:16: error: 'lazy_min' was not declared in this scope
   40 |             if(lazy_min[x << 1].first)
      |                ^~~~~~~~
wall.cpp:42:16: error: 'lazy_min' was not declared in this scope
   42 |             if(lazy_min[(x << 1) | 1].first)
      |                ^~~~~~~~
wall.cpp:44:27: error: 'make_pair' was not declared in this scope
   44 |             lazy_max[x] = make_pair(false, 0);
      |                           ^~~~~~~~~
wall.cpp: In member function 'void Segtree::maximize(int, int, int, int, int, int)':
wall.cpp:51:13: error: 'tree' was not declared in this scope; did you mean 'Segtree'?
   51 |             tree[x].second = max(tree[x].second, h);
      |             ^~~~
      |             Segtree
wall.cpp:51:30: error: 'max' was not declared in this scope
   51 |             tree[x].second = max(tree[x].second, h);
      |                              ^~~
wall.cpp:53:13: error: 'lazy_max' was not declared in this scope
   53 |             lazy_max[x].first = true;
      |             ^~~~~~~~
wall.cpp: In member function 'void Segtree::minimize(int, int, int, int, int, int)':
wall.cpp:67:13: error: 'tree' was not declared in this scope; did you mean 'Segtree'?
   67 |             tree[x].first = min(tree[x].first, h);
      |             ^~~~
      |             Segtree
wall.cpp:67:29: error: 'min' was not declared in this scope
   67 |             tree[x].first = min(tree[x].first, h);
      |                             ^~~
wall.cpp:69:13: error: 'lazy_min' was not declared in this scope
   69 |             lazy_min[x].first = true;
      |             ^~~~~~~~
wall.cpp: In member function 'int Segtree::query(int, int, int, int)':
wall.cpp:83:20: error: 'tree' was not declared in this scope; did you mean 'Segtree'?
   83 |             return tree[x].second;
      |                    ^~~~
      |                    Segtree
wall.cpp: In function 'void buildWall(int, int, int*, int*, int*, int*, int*)':
wall.cpp:95:15: error: 'N' was not declared in this scope
   95 |     tree.init(N);
      |               ^