Submission #749820

#TimeUsernameProblemLanguageResultExecution timeMemory
749820Desh03Aliens (IOI16_aliens)C++17
Compilation error
0 ms0 KiB
#include "aliens.h" #include <bits/stdc++.h> using namespace std; const long long INF = 1e18; struct point { int x, y; bool operator < (const point &p) const { return x == p.x ? y < p.y : x < p.x; } }; long long take_photos(int n, int m, int k, vector<int> R, vector<int> C) { vector<point> f, r; for (int i = 0; i < n; i++) { if (R[i] > C[i]) swap(R[i], C[i]); f.push_back({R[i], C[i]}); } sort(f.begin(), f.end()); f.erase(unique(f.begin(), f.end()), f.end()); r.push_back(f[0]); for (int i = 1; i < n; i++) { if (r.back().x == f[i].x) { r.pop_back(); r.push_back(f[i]); } else if (f[i].y > r.back().y) { r.push_back(f[i]); } } n = r.size(); vector<vector<long long>> dp(k, vector<long long> (n, INF)); for (int i = 0; i < n; i++) dp[0][i] = (long long) (r[i].y - r[0].x + 1) * (r[i].y - r[0].x + 1); auto cost = [&] (const int &i, const int &j) { long long ext = (r[i].x < r[i - 1].y ? (long long) (r[i - 1].y - r[i].x) * (r[i - 1].y - r[i].x) : 0); return (long long) (r[j].y - r[i].x + 1) * (r[j].y - r[i].x + 1) - ext; }; for (int j = 1; j < k; j++) for (int i = j; i < n; i++) { dp[j][i] = dp[j - 1][i]; for (int k = 0; k < i; k++) dp[j][i] = min(dp[j][i], dp[j - 1][k] + cost(k + 1, i)); } long long ans = INF; for (int i = 0; i < k; i++) ans = min(ans, dp[i][n - 1]); return ans; }

Compilation message (stderr)

In file included from /usr/include/c++/10/bits/stl_algobase.h:71,
                 from /usr/include/c++/10/vector:60,
                 from aliens.h:3,
                 from aliens.cpp:1:
/usr/include/c++/10/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_equal_to_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = __gnu_cxx::__normal_iterator<point*, std::vector<point> >; _Iterator2 = __gnu_cxx::__normal_iterator<point*, std::vector<point> >]':
/usr/include/c++/10/bits/stl_algo.h:951:20:   required from '_ForwardIterator std::__unique(_ForwardIterator, _ForwardIterator, _BinaryPredicate) [with _ForwardIterator = __gnu_cxx::__normal_iterator<point*, std::vector<point> >; _BinaryPredicate = __gnu_cxx::__ops::_Iter_equal_to_iter]'
/usr/include/c++/10/bits/stl_algo.h:982:27:   required from '_FIter std::unique(_FIter, _FIter) [with _FIter = __gnu_cxx::__normal_iterator<point*, std::vector<point> >]'
aliens.cpp:21:38:   required from here
/usr/include/c++/10/bits/predefined_ops.h:115:23: error: no match for 'operator==' (operand types are 'point' and 'point')
  115 |       { return *__it1 == *__it2; }
      |                ~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/vector:60,
                 from aliens.h:3,
                 from aliens.cpp:1:
/usr/include/c++/10/bits/stl_iterator.h:1064:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator<_IteratorL, _Container>&, const __gnu_cxx::__normal_iterator<_IteratorR, _Container>&)'
 1064 |     operator==(const __normal_iterator<_IteratorL, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:1064:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/bits/stl_algobase.h:71,
                 from /usr/include/c++/10/vector:60,
                 from aliens.h:3,
                 from aliens.cpp:1:
/usr/include/c++/10/bits/predefined_ops.h:115:23: note:   'point' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>'
  115 |       { return *__it1 == *__it2; }
      |                ~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/vector:60,
                 from aliens.h:3,
                 from aliens.cpp:1:
/usr/include/c++/10/bits/stl_iterator.h:1072:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator<_Iterator, _Container>&, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&)'
 1072 |     operator==(const __normal_iterator<_Iterator, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:1072:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/bits/stl_algobase.h:71,
                 from /usr/include/c++/10/vector:60,
                 from aliens.h:3,
                 from aliens.cpp:1:
/usr/include/c++/10/bits/predefined_ops.h:115:23: note:   'point' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>'
  115 |       { return *__it1 == *__it2; }
      |                ~~~~~~~^~~~~~~~~