Submission #344437

#TimeUsernameProblemLanguageResultExecution timeMemory
344437Sparky_09Aliens (IOI16_aliens)C++17
Compilation error
0 ms0 KiB
#include "bits/stdc++.h"
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define ll long long 
//typedef long long int;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#include "aliens.h"
 
 
long long take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c) {
    
  ll dp[n+10][n+10];
    memset(dp, 0x3f, sizeof dp);
    /*
      dp[ind][k] = min(dp[int-1][k-1]) + area
    */
    vector<pair<int, int>> vpi;
    for(int i = 0; i < n; i++) vpi.emplace_back(c[i], r[i]);
    sort(vpi.begin(), vpi.end());
    dp[0][1] = 1;
  for(int i = 0; i < n; i++) dp[i][0] = 0;
    for(int i = 0; i < n; i++){
      for(int j = 0; j <= i; j++){ // previous one
        for(int l = 1; l <= k; l++){
        	if(j==i){
        	  dp[i][l] = min(dp[i][l], dp[i-1][l-1] + 1);
        	}
          if(l == 1 and j > 0) continue;
          
          int curr, curc, prevr, prevc;
          curc = vpi[i].first; curr = vpi[i].second; 
          prevc = vpi[j].first; prevr = vpi[j].second;
          int area = (curc - prevc + 1) * (curc - prevc + 1);
          if(j == 0){
            dp[i][l] = min(dp[i][l], area);
          }
          else dp[i][l] = min(dp[i][l], dp[j-1][l-1] + area);
        }
      }
    }
		
    return dp[n-1][k];
 
  
}

Compilation message (stderr)

aliens.cpp: In function 'long long int take_photos(int, int, int, std::vector<int>, std::vector<int>)':
aliens.cpp:39:42: error: no matching function for call to 'min(long long int&, int&)'
   39 |             dp[i][l] = min(dp[i][l], area);
      |                                          ^
In file included from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from aliens.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  198 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:198:5: note:   template argument deduction/substitution failed:
aliens.cpp:39:42: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   39 |             dp[i][l] = min(dp[i][l], area);
      |                                          ^
In file included from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from aliens.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  246 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:246:5: note:   template argument deduction/substitution failed:
aliens.cpp:39:42: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   39 |             dp[i][l] = min(dp[i][l], area);
      |                                          ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from aliens.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3444:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3444 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3444:5: note:   template argument deduction/substitution failed:
aliens.cpp:39:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   39 |             dp[i][l] = min(dp[i][l], area);
      |                                          ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from aliens.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
aliens.cpp:39:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   39 |             dp[i][l] = min(dp[i][l], area);
      |                                          ^