Submission #1113630

#TimeUsernameProblemLanguageResultExecution timeMemory
1113630sunboiWall (IOI14_wall)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 2e5 + 10; vector<int> a(N); vector<pair<int, int>> t(4 * N), vector<pair<int, int>> lazy(4 * N); void push(int v, int vl, int vr){ if (lazy[v].second == 1){ int x = lazy[v].first; t[v * 2] = {min(t[v * 2].first, x), min(t[v * 2].second, x)} t[v * 2 + 1] = {min(t[v * 2 + 1].first, x), min(t[v * 2 + 1].second, x)} if (lazy[v * 2].second == 0) lazy[v * 2] = {x, 0}; else lazy[v * 2] = {min(lazy[v * 2].first, x), 0}; if (lazy[v * 2 + 1].second == 0) lazy[v * 2 + 1] = {x, 0}; else lazy[v * 2 + 1] = {min(lazy[v * 2 + 1].first, x), 0}; lazy[v] = {0, 0}; }else{ int x = lazy[v].first; t[v * 2] = {max(t[v * 2].first, x), max(t[v * 2].second, x)} t[v * 2 + 1] = {max(t[v * 2 + 1].first, x), max(t[v * 2 + 1].second, x)} if (lazy[v * 2].second == 1) lazy[v * 2] = {x, 0}; else lazy[v * 2] = {max(lazy[v * 2].first, x), 0}; if (lazy[v * 2 + 1].second == 1) lazy[v * 2 + 1] = {x, 0}; else lazy[v * 2 + 1] = {max(lazy[v * 2 + 1].first, x), 0}; lazy[v] = {0, 0}; } } void build(int v, int vl, int vr) { if (vl == vr) { t[v] = {a[vl], a[vl]}; return; } int vm = (vl + vr) / 2; build(2 * v, vl, vm); build(2 * v + 1, vm + 1, vr); t[v] = {max(t[2 * v], t[2 * v + 1]), min(t[2 * v], t[2 * v + 1])}; } void update(int v, int vl, int vr, int l, int r, int x){ if (vl > r || vr < l) return; if (vl >= l && vr <= r){ t[v] = {max(t[v].first, x), max(t[v].second, x)} if (lazy[v].second == 1) lazy[v] = {x, 0}; else lazy[v] = {max(lazy[v].first, x), 0}; return; } push(v, vl ,vr); int vm = (vl + vr) / 2; update(2 * v, vl, vm, l, r, x); update(2 * v + 1, vm + 1, vr, l, r, x); t[v] = {max(t[2 * v], t[2 * v + 1]), min(t[2 * v], t[2 * v + 1])}; } void update2(int v, int vl, int vr, int l, int r, int x){ if (vl > r || vr < l) return; if (vl >= l && vr <= r){ t[v] = {min(t[v].first, x), min(t[v].second, x)} if (lazy[v].second == 0) lazy[v] = {x, 1}; else lazy[v] = {min(lazy[v].first, x), 0}; return; } push(v, vl ,vr); int vm = (vl + vr) / 2; update2(2 * v, vl, vm, l, r, x); update2(2 * v + 1, vm + 1, vr, l, r, x); t[v] = {max(t[2 * v], t[2 * v + 1]), min(t[2 * v], t[2 * v + 1])}; } int get(int v, int vl, int vr, int x){ if (vl > x || vr < x) return 0; if (vr <= r && l <= vl){ return t[v].first; } push(v, vl, vr); int vm = (vl + vr) / 2; return max(get(2 * v, vl, vm, l, r), get(2 * v + 1, vm + 1, vr, l, r)); } void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){ for (int i = 0; i < n; i++){ a[i] = 0; } build(1, 0, n - 1); for (int i = 0; i < k; i++){ if (op[i] == 1){ update(1, 0, n - 1, left[i], right[i], height[i]); }else update2(1, 0, n - 1, left[i], right[i], height[i]); } for (int i = 0; i < n; i++){ finalHeight[i] = get(1, 0, n - 1, i); } /*for (int x : finalHeight) cout << x << ' '; cout << endl;*/ }

Compilation message (stderr)

wall.cpp:8:24: error: invalid declarator before 'lazy'
    8 | vector<pair<int, int>> lazy(4 * N);
      |                        ^~~~
wall.cpp: In function 'void push(long long int, long long int, long long int)':
wall.cpp:11:9: error: 'lazy' was not declared in this scope
   11 |     if (lazy[v].second == 1){
      |         ^~~~
wall.cpp:13:73: error: expected ';' before 't'
   13 |             t[v * 2] = {min(t[v * 2].first, x), min(t[v * 2].second, x)}
      |                                                                         ^
      |                                                                         ;
   14 |             t[v * 2 + 1] = {min(t[v * 2 + 1].first, x), min(t[v * 2 + 1].second, x)}
      |             ~                                                            
wall.cpp:28:73: error: expected ';' before 't'
   28 |             t[v * 2] = {max(t[v * 2].first, x), max(t[v * 2].second, x)}
      |                                                                         ^
      |                                                                         ;
   29 |             t[v * 2 + 1] = {max(t[v * 2 + 1].first, x), max(t[v * 2 + 1].second, x)}
      |             ~                                                            
wall.cpp: In function 'void build(long long int, long long int, long long int)':
wall.cpp:54:69: error: no match for 'operator=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} and '<brace-enclosed initializer list>')
   54 |     t[v] = {max(t[2 * v], t[2 * v + 1]), min(t[2 * v], t[2 * v + 1])};
      |                                                                     ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from wall.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:390:7: note: candidate: 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(typename std::conditional<std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value, const std::pair<_T1, _T2>&, const std::__nonesuch&>::type) [with _T1 = long long int; _T2 = long long int; typename std::conditional<std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value, const std::pair<_T1, _T2>&, const std::__nonesuch&>::type = const std::pair<long long int, long long int>&]'
  390 |       operator=(typename conditional<
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:393:41: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::conditional<true, const std::pair<long long int, long long int>&, const std::__nonesuch&>::type' {aka 'const std::pair<long long int, long long int>&'}
  390 |       operator=(typename conditional<
      |                 ~~~~~~~~~~~~~~~~~~~~~    
  391 |   __and_<is_copy_assignable<_T1>,
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~        
  392 |          is_copy_assignable<_T2>>::value,
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  393 |   const pair&, const __nonesuch&>::type __p)
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_pair.h:401:7: note: candidate: 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(typename std::conditional<std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value, std::pair<_T1, _T2>&&, std::__nonesuch&&>::type) [with _T1 = long long int; _T2 = long long int; typename std::conditional<std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value, std::pair<_T1, _T2>&&, std::__nonesuch&&>::type = std::pair<long long int, long long int>&&]'
  401 |       operator=(typename conditional<
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:404:31: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::conditional<true, std::pair<long long int, long long int>&&, std::__nonesuch&&>::type' {aka 'std::pair<long long int, long long int>&&'}
  401 |       operator=(typename conditional<
      |                 ~~~~~~~~~~~~~~~~~~~~~
  402 |   __and_<is_move_assignable<_T1>,
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  403 |          is_move_assignable<_T2>>::value,
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  404 |   pair&&, __nonesuch&&>::type __p)
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_pair.h:418:2: note: candidate: 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, const _U1&>, std::is_assignable<_T2&, const _U2&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(const std::pair<_U1, _U2>&) [with _U1 = _U1; _U2 = _U2; _T1 = long long int; _T2 = long long int]'
  418 |  operator=(const pair<_U1, _U2>& __p)
      |  ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:418:2: note:   template argument deduction/substitution failed:
wall.cpp:54:69: note:   couldn't deduce template parameter '_U1'
   54 |     t[v] = {max(t[2 * v], t[2 * v + 1]), min(t[2 * v], t[2 * v + 1])};
      |                                                                     ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from wall.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:430:2: note: candidate: 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, _U1&&>, std::is_assignable<_T2&, _U2&&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(std::pair<_U1, _U2>&&) [with _U1 = _U1; _U2 = _U2; _T1 = long long int; _T2 = long long int]'
  430 |  operator=(pair<_U1, _U2>&& __p)
      |  ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:430:2: note:   template argument deduction/substitution failed:
wall.cpp:54:69: note:   couldn't deduce template parameter '_U1'
   54 |     t[v] = {max(t[2 * v], t[2 * v + 1]), min(t[2 * v], t[2 * v + 1])};
      |                                                                     ^
wall.cpp: In function 'void update(long long int, long long int, long long int, long long int, long long int, long long int)':
wall.cpp:60:57: error: expected ';' before 'if'
   60 |         t[v] = {max(t[v].first, x), max(t[v].second, x)}
      |                                                         ^
      |                                                         ;
   61 | 
   62 |         if (lazy[v].second == 1) lazy[v] = {x, 0};
      |         ~~                                               
wall.cpp:63:9: error: expected '}' before 'else'
   63 |         else lazy[v] = {max(lazy[v].first, x), 0};
      |         ^~~~
wall.cpp:59:28: note: to match this '{'
   59 |     if (vl >= l && vr <= r){
      |                            ^
wall.cpp:63:14: error: 'lazy' was not declared in this scope
   63 |         else lazy[v] = {max(lazy[v].first, x), 0};
      |              ^~~~
wall.cpp: At global scope:
wall.cpp:67:9: error: expected constructor, destructor, or type conversion before '(' token
   67 |     push(v, vl ,vr);
      |         ^
wall.cpp:68:15: error: 'vl' was not declared in this scope; did you mean 'vm'?
   68 |     int vm = (vl + vr) / 2;
      |               ^~
      |               vm
wall.cpp:68:20: error: 'vr' was not declared in this scope; did you mean 'vm'?
   68 |     int vm = (vl + vr) / 2;
      |                    ^~
      |                    vm
wall.cpp:70:11: error: expected constructor, destructor, or type conversion before '(' token
   70 |     update(2 * v, vl, vm, l, r, x);
      |           ^
wall.cpp:71:11: error: expected constructor, destructor, or type conversion before '(' token
   71 |     update(2 * v + 1, vm + 1, vr, l, r, x);
      |           ^
wall.cpp:73:5: error: 't' does not name a type
   73 |     t[v] = {max(t[2 * v], t[2 * v + 1]), min(t[2 * v], t[2 * v + 1])};
      |     ^
wall.cpp:74:1: error: expected declaration before '}' token
   74 | }
      | ^
wall.cpp: In function 'void update2(long long int, long long int, long long int, long long int, long long int, long long int)':
wall.cpp:79:57: error: expected ';' before 'if'
   79 |         t[v] = {min(t[v].first, x), min(t[v].second, x)}
      |                                                         ^
      |                                                         ;
   80 | 
   81 |         if (lazy[v].second == 0) lazy[v] = {x, 1};
      |         ~~                                               
wall.cpp:82:9: error: expected '}' before 'else'
   82 |         else lazy[v] = {min(lazy[v].first, x), 0};
      |         ^~~~
wall.cpp:78:28: note: to match this '{'
   78 |     if (vl >= l && vr <= r){
      |                            ^
wall.cpp:82:14: error: 'lazy' was not declared in this scope
   82 |         else lazy[v] = {min(lazy[v].first, x), 0};
      |              ^~~~
wall.cpp: At global scope:
wall.cpp:86:9: error: expected constructor, destructor, or type conversion before '(' token
   86 |     push(v, vl ,vr);
      |         ^
wall.cpp:87:9: error: redefinition of 'long long int vm'
   87 |     int vm = (vl + vr) / 2;
      |         ^~
wall.cpp:68:9: note: 'long long int vm' previously defined here
   68 |     int vm = (vl + vr) / 2;
      |         ^~
wall.cpp:87:15: error: 'vl' was not declared in this scope; did you mean 'vm'?
   87 |     int vm = (vl + vr) / 2;
      |               ^~
      |               vm
wall.cpp:87:20: error: 'vr' was not declared in this scope; did you mean 'vm'?
   87 |     int vm = (vl + vr) / 2;
      |                    ^~
      |                    vm
wall.cpp:89:12: error: expected constructor, destructor, or type conversion before '(' token
   89 |     update2(2 * v, vl, vm, l, r, x);
      |            ^
wall.cpp:90:12: error: expected constructor, destructor, or type conversion before '(' token
   90 |     update2(2 * v + 1, vm + 1, vr, l, r, x);
      |            ^
wall.cpp:92:5: error: 't' does not name a type
   92 |     t[v] = {max(t[2 * v], t[2 * v + 1]), min(t[2 * v], t[2 * v + 1])};
      |     ^
wall.cpp:93:1: error: expected declaration before '}' token
   93 | }
      | ^
wall.cpp: In function 'long long int get(long long int, long long int, long long int, long long int)':
wall.cpp:97:15: error: 'r' was not declared in this scope
   97 |     if (vr <= r && l <= vl){
      |               ^
wall.cpp:97:20: error: 'l' was not declared in this scope
   97 |     if (vr <= r && l <= vl){
      |                    ^
wall.cpp:104:35: error: 'l' was not declared in this scope
  104 |     return max(get(2 * v, vl, vm, l, r), get(2 * v + 1, vm + 1, vr, l, r));
      |                                   ^
wall.cpp:104:38: error: 'r' was not declared in this scope
  104 |     return max(get(2 * v, vl, vm, l, r), get(2 * v + 1, vm + 1, vr, l, r));
      |                                      ^