Submission #889372

#TimeUsernameProblemLanguageResultExecution timeMemory
889372ASN49KAliens (IOI16_aliens)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "aliens.h" using namespace std; using i64=long long; const i64 INF=1e18; #define bug(x) cerr<<#x<<x<<'\n'; #define all(yy) yy.begin(),yy.end() #define pb push_back const int inf=1e9; struct duo { int l,r; bool operator <(const duo&b)const { if(l==b.l) { return r>b.r; } return l<b.l; } }; ////////////////////////////GEOMETRY //////////////////////////////////// struct line { i64 a,b; i64 calculate(int x) { return a*x+b; } }; i64 intersect(const line& c,const line& d) { return (d.b-c.b+c.a-d.a-1)/(c.a-d.a); } struct CHT { deque<line>d; void add(const line e) { while(d.size()>=2 && intersect(d[d.size()-2],d.back())>=intersect(d.back(),e)) { d.pop_back(); } d.pb(e); } i64 query(int val) { while(d.size()>=2 && d[0].calculate(val)>=d[1].calculate(val)) { d.pop_front(); } return d[0].calculate(val); } void clear() { d.clear(); } }; i64 pow2(i64 x) { return x*x; } ///////////////////////////////////////////////////// ///////////////////////////////////////////////////// i64 take_photos(int n, int m, int k, vector<int> rr, vector<int> cc) { vector<duo>a(n); for(int i=0;i<n;i++) { a[i]={min(rr[i],cc[i]),max(rr[i],cc[i])}; } vector<duo>aux=a; a.clear(); sort(all(aux)); int maxx=-1; for(auto &c:aux) { if(c.r>maxx) { a.pb(c); maxx=c.r; } } aux.clear(); n=(int)a.size(); vector<i64>dp(n,INF); for(int _=0;_<k;_++) { for(int i=n-1;i>=_;i--) { dp[i]=pow2(a[i].r-a[0].l+1); for(int j=i-1;j>=0;j--) { dp[i]=min(dp[i],pow2(a[i].r)-2*(a[j+1].l-1)*a[i].r+pow2(a[j+1].l-1)+pow2(max(0LL,a[j].r-a[j+1].l+1))+dp[j]); } } } return dp[n-1]; }

Compilation message (stderr)

aliens.cpp: In function 'i64 take_photos(int, int, int, std::vector<int>, std::vector<int>)':
aliens.cpp:95:115: error: no matching function for call to 'max(long long int, int)'
   95 |                 dp[i]=min(dp[i],pow2(a[i].r)-2*(a[j+1].l-1)*a[i].r+pow2(a[j+1].l-1)+pow2(max(0LL,a[j].r-a[j+1].l+1))+dp[j]);
      |                                                                                                                   ^
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 aliens.cpp:1:
/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:
aliens.cpp:95:115: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   95 |                 dp[i]=min(dp[i],pow2(a[i].r)-2*(a[j+1].l-1)*a[i].r+pow2(a[j+1].l-1)+pow2(max(0LL,a[j].r-a[j+1].l+1))+dp[j]);
      |                                                                                                                   ^
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 aliens.cpp:1:
/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:
aliens.cpp:95:115: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   95 |                 dp[i]=min(dp[i],pow2(a[i].r)-2*(a[j+1].l-1)*a[i].r+pow2(a[j+1].l-1)+pow2(max(0LL,a[j].r-a[j+1].l+1))+dp[j]);
      |                                                                                                                   ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from aliens.cpp:1:
/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:
aliens.cpp:95:115: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   95 |                 dp[i]=min(dp[i],pow2(a[i].r)-2*(a[j+1].l-1)*a[i].r+pow2(a[j+1].l-1)+pow2(max(0LL,a[j].r-a[j+1].l+1))+dp[j]);
      |                                                                                                                   ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from aliens.cpp:1:
/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:
aliens.cpp:95:115: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   95 |                 dp[i]=min(dp[i],pow2(a[i].r)-2*(a[j+1].l-1)*a[i].r+pow2(a[j+1].l-1)+pow2(max(0LL,a[j].r-a[j+1].l+1))+dp[j]);
      |                                                                                                                   ^