제출 #1084849

#제출 시각아이디문제언어결과실행 시간메모리
1084849fyanAliens (IOI16_aliens)C++14
컴파일 에러
0 ms0 KiB
#include "bits/stdc++.h" using namespace std; #define int int64_t #define all(x) begin(x), end(x) #define sz(x) (int) (x).size() const int MXN=4e3+5, INF=1e9; int N,M,K; array<int,2> arr[MXN]; int dp[MXN][MXN]; bool cc1(const array<int,2> &a, const array<int,2> &b) { if (a[0]==b[0]) { return a[1]>b[1]; } return a[0]<b[0]; } bool cc2(const array<int,2> &a, const array<int,2> &b) { return a[1]<b[1]; } int take_photos(int n, int m, int k, vector<int> r, vector<int> c) { N = n, M = m, K = min(k,N); for (int i=1; i<=N; i++) { arr[i] = {min(r[i-1],c[i-1]),max(r[i-1],c[i-1])}; } arr[0] = {-INF,-INF}; sort(arr,arr+N+1,cc1); int pv = 0,sub = 0; for (int i=1; i<=N; i++) { if (arr[pv][1] >= arr[i][1]) { sub++; arr[i] = {INF,INF}; } else pv = i; } sort(arr,arr+1+N,cc2); N -= sub; K = min(K,N); memset(dp,0x3f,sizeof(dp)); dp[0][0] = 0; for (int i=1; i<=N; i++) { for (int j=1; j<=K; j++) { for (int p=0; p<i; p++) { int area = (arr[i][1]-arr[p+1][0]+1)*(arr[i][1]-arr[p+1][0]+1); int dif = 1ll*max(0,arr[p][1]-arr[p+1][0]+1)*max(0,arr[p][1]-arr[p+1][0]+1); area -= dif; dp[i][j] = min(dp[i][j],dp[p][j-1]+area); } } } return dp[N][K]; } /* signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); int a,b,c; cin>>a>>b>>c; vector<int> x(a),y(a); for (int i=0; i<a; i++) { cin>>x[i]>>y[i]; } cout<<take_photos(a,b,c,x,y); return 0; } */

컴파일 시 표준 에러 (stderr) 메시지

aliens.cpp: In function 'int64_t take_photos(int64_t, int64_t, int64_t, std::vector<long int>, std::vector<long int>)':
aliens.cpp:45:48: error: no matching function for call to 'max(int, std::array<long int, 2>::value_type)'
   45 |     int dif = 1ll*max(0,arr[p][1]-arr[p+1][0]+1)*max(0,arr[p][1]-arr[p+1][0]+1);
      |                                                ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 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:45:48: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::array<long int, 2>::value_type' {aka 'long int'})
   45 |     int dif = 1ll*max(0,arr[p][1]-arr[p+1][0]+1)*max(0,arr[p][1]-arr[p+1][0]+1);
      |                                                ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 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:45:48: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::array<long int, 2>::value_type' {aka 'long int'})
   45 |     int dif = 1ll*max(0,arr[p][1]-arr[p+1][0]+1)*max(0,arr[p][1]-arr[p+1][0]+1);
      |                                                ^
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:45:48: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   45 |     int dif = 1ll*max(0,arr[p][1]-arr[p+1][0]+1)*max(0,arr[p][1]-arr[p+1][0]+1);
      |                                                ^
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:45:48: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   45 |     int dif = 1ll*max(0,arr[p][1]-arr[p+1][0]+1)*max(0,arr[p][1]-arr[p+1][0]+1);
      |                                                ^
aliens.cpp:45:79: error: no matching function for call to 'max(int, std::array<long int, 2>::value_type)'
   45 |     int dif = 1ll*max(0,arr[p][1]-arr[p+1][0]+1)*max(0,arr[p][1]-arr[p+1][0]+1);
      |                                                                               ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 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:45:79: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::array<long int, 2>::value_type' {aka 'long int'})
   45 |     int dif = 1ll*max(0,arr[p][1]-arr[p+1][0]+1)*max(0,arr[p][1]-arr[p+1][0]+1);
      |                                                                               ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 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:45:79: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::array<long int, 2>::value_type' {aka 'long int'})
   45 |     int dif = 1ll*max(0,arr[p][1]-arr[p+1][0]+1)*max(0,arr[p][1]-arr[p+1][0]+1);
      |                                                                               ^
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:45:79: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   45 |     int dif = 1ll*max(0,arr[p][1]-arr[p+1][0]+1)*max(0,arr[p][1]-arr[p+1][0]+1);
      |                                                                               ^
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:45:79: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   45 |     int dif = 1ll*max(0,arr[p][1]-arr[p+1][0]+1)*max(0,arr[p][1]-arr[p+1][0]+1);
      |                                                                               ^