Submission #1019926

#TimeUsernameProblemLanguageResultExecution timeMemory
1019926overwatch9Meetings (IOI18_meetings)C++17
Compilation error
0 ms0 KiB
#include "meetings.h" #include <bits/stdc++.h> using namespace std; using ll = long long; struct stree { #define lc v*2 #define rc v*2+1 vector <ll> tree; stree (int s) { tree.resize(s * 4, 1e18); } void pushup(int v) { tree[v] = min(tree[lc], tree[rc]); } void update(int v, int tl, int tr, int p, ll val) { if (tl > p || tr < p) return; if (tl == tr) { tree[v] = val; return; } int tm = (tl + tr) / 2; update(lc, tl, tm, p, val); update(rc, tm+1, tr, p, val); pushup(v); } ll query(int v, int tl, int tr, int l, int r) { if (tl > r || tr < l) return 1e18; if (tl >= l && tr <= r) return tree[v]; int tm = (tl + tr) / 2; ll a = query(lc, tl, tm, l, r); ll b = query(rc, tm+1, tr, l, r); return min(a, b); } }; vector<ll> minimum_costs(vector<int> h, vector<int> L, vector<int> R) { int Q = L.size(); int n = h.size(); stree tree(n+1); vector <ll> lsum(n), rsum(n); lsum[0] = h[0]; for (int i = 1; i < n; i++) { lsum[i] = lsum[i-1]; if (h[i] == 2) lsum[i] = (i+1) * 2; else lsum[i]++; } rsum[n-1] = h[n-1]; for (int i = n-2; i >= 0; i--) { rsum[i] = rsum[i+1]; if (h[i] == 2) rsum[i] = (n - i) * 2; else rsum[i]++; } for (int i = 0; i < n; i++) { if (h[i] == 1) tree.update(1, 0, n, i, lsum[i] + rsum[i] - h[i]); // cout << "sum: " << lsum[i] << ' ' << rsum[i] << '\n'; } vector <ll> ans(Q); for (int i = 0; i < Q; i++) { ll x = tree.query(1, 0, n, L[i], R[i]); // cout << "x: " << x << '\n'; x -= lsum[L[i]]; x -= rsum[R[i]]; x += h[L[i]]; x += h[R[i]]; ans[i] = min(x, (R[i] - L[i] + 1) * 2); } return ans; } // int main() { // int n, q; // cin >> n >> q; // vector <int> h(n); // for (int i = 0; i < n; i++) // cin >> h[i]; // vector <int> l(q), r(q); // for (int i = 0; i < q; i++) // cin >> l[i] >> r[i]; // auto res = minimum_costs(h, l, r); // }

Compilation message (stderr)

meetings.cpp: In function 'std::vector<long long int> minimum_costs(std::vector<int>, std::vector<int>, std::vector<int>)':
meetings.cpp:73:40: error: no matching function for call to 'min(ll&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
   73 |   ans[i] = min(x, (R[i] - L[i] + 1) * 2);
      |                                        ^
In file included from /usr/include/c++/10/vector:60,
                 from meetings.h:3,
                 from meetings.cpp:1:
/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:
meetings.cpp:73:40: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   73 |   ans[i] = min(x, (R[i] - L[i] + 1) * 2);
      |                                        ^
In file included from /usr/include/c++/10/vector:60,
                 from meetings.h:3,
                 from meetings.cpp:1:
/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:
meetings.cpp:73:40: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   73 |   ans[i] = min(x, (R[i] - L[i] + 1) * 2);
      |                                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from meetings.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:
meetings.cpp:73:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   73 |   ans[i] = min(x, (R[i] - L[i] + 1) * 2);
      |                                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from meetings.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:
meetings.cpp:73:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   73 |   ans[i] = min(x, (R[i] - L[i] + 1) * 2);
      |                                        ^