답안 #871727

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
871727 2023-11-11T11:53:08 Z Nonoze 메기 농장 (IOI22_fish) C++17
컴파일 오류
0 ms 0 KB
#include "fish.h"
//include "grader.cpp"

#include <bits/stdc++.h>
using namespace std;
#define int long long

map<pair<int, pair<int, int>>, int> memo;
vector<vector<int>> values;
int n;

int dp(int empl, int take, int pretake) {
	if (empl>=n) return 0;
	if (memo.count({empl, {take, pretake}})) return memo[{empl, {take, pretake}}];
	int ans=dp(empl+1, 0, take);
	int sum=0;
	for (int i=0; i<min(n, 8); i++) {
		int temp=dp(empl+1, i, take);
		if ((pretake&(1<<i))!=(1<<i) && (take&(1<<i))!=(1<<i) && empl>0) {
			sum+=values[empl-1][i];
		}
		if (empl+1<n) sum+=values[empl+1][i];
		if ((take&(1<<i))==(1<<i)) sum-=values[empl][i];
		ans=max(ans, temp+sum);
	}
	return memo[{empl, {take, pretake}}]=ans;
}

#undef int
long long max_weights(int N, int m, vector<int> x, vector<int> y, vector<int> w) {
	#define int long long
	n=N;
	bool tacha=true, tachb=true, tachc=true;
	for (int i = 0; i < m; ++i)
	{
		if (x[i]%2) tacha=false;
		if (x[i]>1) tachb=false;
		if (y[i]) tachc=false;
	}
	if (tacha)
	{
		int ans=0;
		for (int i = 0; i < m; ++i) ans+=w[i];
		return ans;
	}
	if (tachb)
	{
		vector<vector<int>> farm(2, vector<int> (n, 0));
		for (int i=0; i<m; i++) {
			farm[x[i]][y[i]]=w[i];
		}
		vector<int> suml, sumr;
		suml.push_back(farm[0][0]);
		sumr.push_back(farm[1][0]);
		for (int i=1; i<n; i++) {
			suml.push_back(suml.back()+farm[0][i]);
			sumr.push_back(sumr.back()+farm[1][i]);
		}
		if (n==2) return max(suml.back(), sumr.back());
		int ans=sumr.back();
		for (int i=0; i<n; i++) {
			ans=max(ans, suml[i]+sumr.back()-sumr[i]);
		}
		return ans;
	}
	values.resize(n, vector<int>(8, 0));
	for (int i=0; i<m; i++) {
		values[x[i]][y[i]]=w[i];
	}
	return dp(0, 0, 0);
	#undef int
}

Compilation message

fish.cpp: In function 'long long int dp(long long int, long long int, long long int)':
fish.cpp:17:26: error: no matching function for call to 'min(long long int&, int)'
   17 |  for (int i=0; i<min(n, 8); i++) {
      |                          ^
In file included from /usr/include/c++/10/vector:60,
                 from fish.h:1,
                 from fish.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
fish.cpp:17:26: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   17 |  for (int i=0; i<min(n, 8); i++) {
      |                          ^
In file included from /usr/include/c++/10/vector:60,
                 from fish.h:1,
                 from fish.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
fish.cpp:17:26: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   17 |  for (int i=0; i<min(n, 8); i++) {
      |                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from fish.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
fish.cpp:17:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   17 |  for (int i=0; i<min(n, 8); i++) {
      |                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from fish.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
fish.cpp:17:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   17 |  for (int i=0; i<min(n, 8); i++) {
      |                          ^