Submission #722239

# Submission time Handle Problem Language Result Execution time Memory
722239 2023-04-11T15:37:40 Z joelgun14 Wall (IOI14_wall) C++17
Compilation error
0 ms 0 KB
#include "wall.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int lim = 1 << 13;
struct segment_tree {
  ll lazymax[2 * lim], lazymin[2 * lim], a[2 * lim];
  segment_tree() {
    memset(a, 0, sizeof(a));
    fill(lazymin, lazymin + 2 * lim, 4e18);
    memset(lazymax, 0, sizeof(lazymax));
  }
  void propagate(int nd, int cl, int cr) {
    if(cl == cr) {
      a[nd] = max(lazymax[nd], a[nd]);
      a[nd] = min(lazymin[nd], a[nd]);
    }
    else {
      lazymax[2 * nd] = min(lazymin[nd], max(lazymax[2 * nd], lazymax[nd]));
      lazymin[2 * nd] = max(min(lazymin[2 * nd], lazymin[nd]), lazymax[nd]);
      lazymax[2 * nd + 1] = min(lazymin[nd], max(lazymax[2 * nd + 1], lazymax[nd]));
      lazymin[2 * nd + 1] = max(min(lazymin[2 * nd + 1], lazymin[nd]), lazymax[nd]);
    }
    lazymax[nd] = 0, lazymin[nd] = 4e18;
  }
  void update_max(int nd, int cl, int cr, int l, int r, int val) {
    propagate(nd, cl, cr);
    if(cl >= l && cr <= r) {
      lazymax[nd] = max(lazymax[nd], val);
      lazymin[nd] = max(lazymin[nd], val);
      propagate(nd, cl, cr);
    }
    else if(cl > r || cr < l) {
      return;
    }
    else {
      int mid = (cl + cr) / 2;
      update_max(2 * nd, cl, mid, l, r, val);
      update_max(2 * nd + 1, mid + 1, cr, l, r, val);
    }
  }
  void update_min(int nd, int cl, int cr, int l, int r, int val) {
    propagate(nd, cl, cr);
    if(cl >= l && cr <= r) {
      lazymax[nd] = min(lazymax[nd], val);
      lazymin[nd] = min(lazymin[nd], val);
      propagate(nd, cl, cr);
    }
    else if(cl > r || cr < l) {
      return;
    }
    else {
      int mid = (cl + cr) / 2;
      update_min(2 * nd, cl, mid, l, r, val);
      update_min(2 * nd + 1, mid + 1, cr, l, r, val);
    }
  }
  int query(int nd, int cl, int cr, int idx) {
    propagate(nd, cl, cr);
    if(cl == cr) {
      return a[nd];
    }
    else {
      int mid = (cl + cr) / 2;
      if(idx <= mid)
        return query(2 * nd, cl, mid, idx);
      else
        return query(2 * nd + 1, mid + 1, cr, idx);
    }
  }
};
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
  segment_tree seg;
  //cout << "SUCCEED 1 " << endl;
  for(int i = 0; i < k; ++i) {
    //cout << i << endl;
    if(op[i] == 1) {
      // max
      seg.update_max(1, 0, lim - 1, left[i], right[i], height[i]);
    }
    else {
      seg.update_min(1, 0, lim - 1, left[i], right[i], height[i]);
    }
  }
  for(int i = 0; i < n; ++i)
    finalHeight[i] = seg.query(1, 0, lim - 1, i);
  return;
}

Compilation message

wall.cpp: In member function 'void segment_tree::update_max(int, int, int, int, int, int)':
wall.cpp:29:41: error: no matching function for call to 'max(long long int&, int&)'
   29 |       lazymax[nd] = max(lazymax[nd], val);
      |                                         ^
In file included 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:2:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
wall.cpp:29:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   29 |       lazymax[nd] = max(lazymax[nd], val);
      |                                         ^
In file included 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:2:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
wall.cpp:29:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   29 |       lazymax[nd] = max(lazymax[nd], val);
      |                                         ^
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:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
wall.cpp:29:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   29 |       lazymax[nd] = max(lazymax[nd], val);
      |                                         ^
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: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
wall.cpp:29:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   29 |       lazymax[nd] = max(lazymax[nd], val);
      |                                         ^
wall.cpp:30:41: error: no matching function for call to 'max(long long int&, int&)'
   30 |       lazymin[nd] = max(lazymin[nd], val);
      |                                         ^
In file included 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:2:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
wall.cpp:30:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   30 |       lazymin[nd] = max(lazymin[nd], val);
      |                                         ^
In file included 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:2:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
wall.cpp:30:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   30 |       lazymin[nd] = max(lazymin[nd], val);
      |                                         ^
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:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
wall.cpp:30:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   30 |       lazymin[nd] = max(lazymin[nd], val);
      |                                         ^
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: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
wall.cpp:30:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   30 |       lazymin[nd] = max(lazymin[nd], val);
      |                                         ^
wall.cpp: In member function 'void segment_tree::update_min(int, int, int, int, int, int)':
wall.cpp:45:41: error: no matching function for call to 'min(long long int&, int&)'
   45 |       lazymax[nd] = min(lazymax[nd], val);
      |                                         ^
In file included 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:2:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
wall.cpp:45:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   45 |       lazymax[nd] = min(lazymax[nd], val);
      |                                         ^
In file included 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:2:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
wall.cpp:45:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   45 |       lazymax[nd] = min(lazymax[nd], val);
      |                                         ^
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:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
wall.cpp:45:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   45 |       lazymax[nd] = min(lazymax[nd], val);
      |                                         ^
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: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
wall.cpp:45:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   45 |       lazymax[nd] = min(lazymax[nd], val);
      |                                         ^
wall.cpp:46:41: error: no matching function for call to 'min(long long int&, int&)'
   46 |       lazymin[nd] = min(lazymin[nd], val);
      |                                         ^
In file included 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:2:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
wall.cpp:46:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   46 |       lazymin[nd] = min(lazymin[nd], val);
      |                                         ^
In file included 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:2:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
wall.cpp:46:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   46 |       lazymin[nd] = min(lazymin[nd], val);
      |                                         ^
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:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
wall.cpp:46:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   46 |       lazymin[nd] = min(lazymin[nd], val);
      |                                         ^
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: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
wall.cpp:46:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   46 |       lazymin[nd] = min(lazymin[nd], val);
      |                                         ^