Submission #682874

# Submission time Handle Problem Language Result Execution time Memory
682874 2023-01-17T06:54:02 Z irmuun Catfish Farm (IOI22_fish) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#include "fish.h"
using namespace std;
#define ll long long
long long max_weights(int n,int m,vector<int>x,vector<int>y,vector<int>w){
	int count=0,X=-1,Y=-1;
	for(int i=0;i<m;i++){
		if(x[i]%2==0){
			count++;
		}
		X=max(X,x[i]);
		Y=max(Y,y[i]);
	}
	if(count==m){//subtask1
		ll ans=0;
		for(int i=0;i<m;i++){
			ans+=w[i];
		}
		return ans;
	}
	if(X<=1){//subtask2
		ll res=0;
		int dp[n+5][2];
		for(int i=0;i<=n;i++){
			dp[i][0]=0;
			dp[i][1]=0;
		}
		ll ans;
		for(int i=0;i<m;i++){
			if(x[i]==1){
				res+=w[i];
			}
			dp[y[i]+1][x[i]]=w[i];
		}
		if(n==2){
			return max(dp[1][0]+dp[2][0],dp[1][1]+dp[2][1]);
		}
		ans=res;
		for(int i=1;i<=n;i++){
			res+=dp[i][0]-dp[i][1];
			ans=max(ans,res);
		}
		return ans;
	}
	if(Y==0){
		int arr[n+5];
		fill(arr,arr+n+3,0);
		for(int i=0;i<m;i++){
			arr[x[i]+1]=w[i];
		}
		ll dp[n+5][2][2];//current pos, current state,current-1 state
		dp[1][0][0]=0;
		dp[1][1][0]=0;
		dp[1][0][1]=0;
		dp[1][1][1]=0;
		for(int i=2;i<=n;i++){
			dp[i][1][1]=max(dp[i-1][1][0],dp[i-1][1][1]);
			dp[i][1][0]=max(dp[i-1][0][1],dp[i-1][0][0]+arr[i]);
			dp[i][0][1]=max(dp[i-1][1][0],dp[i-1][1][1])+arr[i];
			dp[i][0][0]=max(dp[i-1][0][1],dp[i-1][0][0]);
		}
		return max({dp[n][0][0],dp[n][0][1],dp[n][1][0],dp[1][1]});
	}
}

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:62:60: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
   62 |   return max({dp[n][0][0],dp[n][0][1],dp[n][1][0],dp[1][1]});
      |                                                            ^
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 fish.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:
fish.cpp:62:60: note:   candidate expects 2 arguments, 1 provided
   62 |   return max({dp[n][0][0],dp[n][0][1],dp[n][1][0],dp[1][1]});
      |                                                            ^
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 fish.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:
fish.cpp:62:60: note:   candidate expects 3 arguments, 1 provided
   62 |   return max({dp[n][0][0],dp[n][0][1],dp[n][1][0],dp[1][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 fish.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:
fish.cpp:62:60: note:   deduced conflicting types for parameter '_Tp' ('long long int' and 'long long int*')
   62 |   return max({dp[n][0][0],dp[n][0][1],dp[n][1][0],dp[1][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 fish.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:
fish.cpp:62:60: note:   deduced conflicting types for parameter '_Tp' ('long long int' and 'long long int*')
   62 |   return max({dp[n][0][0],dp[n][0][1],dp[n][1][0],dp[1][1]});
      |                                                            ^