Submission #1284106

#TimeUsernameProblemLanguageResultExecution timeMemory
1284106Martincho506Aliens (IOI16_aliens)C++20
Compilation error
0 ms0 KiB
#include<iostream> #include<vector> #include<algorithm> using namespace std; const int MAXN = 4e3+7, INF = 1e18; pair<int, int> tt[MAXN]; vector<pair<int, int> > a; long long dp[MAXN][MAXN]; bool cmp(pair<int, int> a1, pair<int, int> b1) { if(a1.first < b1.first) return true; if(a1.first > b1.first) return false; if(a1.second > b1.second) return true; return false; } long long take_photos(int n, int m, int k, vector<int> r, vector<int> c) { for(int i = 1; i <= n; i++) { tt[i].first = min(c[i-1], r[i-1]); tt[i].second = max(c[i-1], r[i-1]); } sort(tt+1, tt+n+1, cmp); int maxi = 0; for(int i = 1; i <= n; i++) { if(tt[i].second > maxi) { maxi = tt[i].second; a.push_back(tt[i]); } } //cout<<a.size()<<"\n"; //dp[n][k] = min{dp[p][k-1]+(r[n]-l[p+1])^2-max(0, r[p]-l[p+1])^2}; for(int i = 0; i < a.size(); i++) { dp[i][1] = (a[i].second-a[0].first+1)*(a[i].second-a[0].first+1); } for(int i = 1; i <= k; i++) { dp[0][i] = (a[0].second-a[0].first+1)*(a[0].second-a[0].first+1); } for(int i = 2; i <= k; i++) { for(int j = 1; j < a.size(); j++) { long long mini = INF; for(int jj = 0; jj < j; jj++) { int ss = max(0LL, a[jj].second-a[jj+1].first+1); //cout<<i<<" "<<j<<" "<<jj<<" "<<dp[jj][i-1]+(a[j].second-a[jj+1].first+1)*(a[j].second-a[jj+1].first+1)-ss*ss<<"\n"; mini = min(mini, dp[jj][i-1]+(a[j].second-a[jj+1].first+1)*(a[j].second-a[jj+1].first+1)-ss*ss); } dp[j][i] = mini; } } /*for(int i = 0; i < a.size(); i++) { for(int j = 1; j <= k; j++) { cout<<dp[i][j]<<" "; } cout<<"\n"; }*/ int sz = a.size()-1; return dp[sz][k]; } /* 5 7 2 0 3 4 4 4 6 4 5 4 6 */ /*int main() { return 0; }*/

Compilation message (stderr)

aliens.cpp:6:31: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
    6 | const int MAXN = 4e3+7, INF = 1e18;
      |                               ^~~~
aliens.cpp: In function 'long long int take_photos(int, int, int, std::vector<int>, std::vector<int>)':
aliens.cpp:53:29: error: no matching function for call to 'max(long long int, int)'
   53 |                 int ss = max(0LL, a[jj].second-a[jj+1].first+1);
      |                          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/string:51,
                 from /usr/include/c++/13/bits/locale_classes.h:40,
                 from /usr/include/c++/13/bits/ios_base.h:41,
                 from /usr/include/c++/13/ios:44,
                 from /usr/include/c++/13/ostream:40,
                 from /usr/include/c++/13/iostream:41,
                 from aliens.cpp:1:
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
aliens.cpp:53:29: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   53 |                 int ss = max(0LL, a[jj].second-a[jj+1].first+1);
      |                          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
aliens.cpp:53:29: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   53 |                 int ss = max(0LL, a[jj].second-a[jj+1].first+1);
      |                          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61,
                 from aliens.cpp:3:
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
aliens.cpp:53:29: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   53 |                 int ss = max(0LL, a[jj].second-a[jj+1].first+1);
      |                          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
aliens.cpp:53:29: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   53 |                 int ss = max(0LL, a[jj].second-a[jj+1].first+1);
      |                          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
aliens.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
aliens_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~