Submission #632504

# Submission time Handle Problem Language Result Execution time Memory
632504 2022-08-20T08:24:13 Z Red_Inside Catfish Farm (IOI22_fish) C++17
Compilation error
0 ms 0 KB
#include "fish.h"
//
#include <bits/stdc++.h>

#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define FOR(i, j, n) for(int j = i; j < n; ++j)
#define forn(i, j, n) for(int j = i; j <= n; ++j)
#define nfor(i, j, n) for(int j = n; j >= i; --j)
#define all(v) v.begin(), v.end()
#define ld long double
#define ull unsigned long long

using namespace std;
const int maxn=5000+100,LOG=20,mod=998244353;
int block = 106, timer = 0;
const ld EPS = 1e-18;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define bt(i) (1 << (i))
//#define int ll
const int inf=2e9;
#define y1 yy
#define prev pre
#define pii pair <int, int>

ll n, a[maxn][maxn], dp[maxn][maxn][2], dp1[maxn], dp2[maxn];
ll pref[maxn][maxn];

ll max_weights(int N, int m, vector <int> x, vector <int> y, vector <int> c)
{
	n = N;
	forn(0, i, m-1)
	{
		a[x[i]+1][y[i]+1] = c[i];
	}
	forn(1, i, n)
	{
		forn(1, j, n)
		{
			pref[i][j] = pref[i][j-1] + a[i][j];
		}
	}
	forn(1, j, n)
	{
		dp[1][j][0] = 0;
		dp[1][j][1] = -inf;
	}
	dp1[1] = 0;
	dp2[1] = 0;
	forn(2, i, n)
	{
		dp1[i] = 0;
		forn(1, j, n)
		{
			dp[i][j][0] = dp2[i-1]+pref[i-1][j];
			forn(1, k, j-1)
			{
				dp[i][j][0] = max(dp[i - 1][k][0] + pref[i-1][j] - pref[i-1][k],
				dp[i][j][0]);
			}
			dp[i][j][1] = -inf;
			forn(j + 1, k, n)
			{
				dp[i][j][1] = max(dp[i][j][1], max(dp[i-1][k][0], dp[i-1][k][1])
				+pref[i][k]-pref[i][j]);
			}
			dp1[i] = max(dp1[i], max(dp[i-1][j][1], dp[i-1][j][0]) + pref[i][j]);
//			cout << i << " " << j << " " << dp[i][j][0] << " " << dp[i][j][1] << endl;
		}
		dp2[i] = max(dp2[i - 1], dp1[i - 1]);
	}
	int ans = 0;
	forn(1, j, n)
	{
		ans = max(ans, dp[n][j][0]);
		ans = max(ans, dp[n][j][1]);
	}
	ans = max(ans, dp1[n]);
	ans = max(ans, dp2[n]);
	return ans;
}

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:81:29: error: no matching function for call to 'max(int&, long long int&)'
   81 |   ans = max(ans, dp[n][j][0]);
      |                             ^
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: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:81:29: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   81 |   ans = max(ans, dp[n][j][0]);
      |                             ^
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: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:81:29: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   81 |   ans = max(ans, dp[n][j][0]);
      |                             ^
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:3:
/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:81:29: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   81 |   ans = max(ans, dp[n][j][0]);
      |                             ^
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:3:
/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:81:29: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   81 |   ans = max(ans, dp[n][j][0]);
      |                             ^
fish.cpp:82:29: error: no matching function for call to 'max(int&, long long int&)'
   82 |   ans = max(ans, dp[n][j][1]);
      |                             ^
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: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:82:29: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   82 |   ans = max(ans, dp[n][j][1]);
      |                             ^
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: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:82:29: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   82 |   ans = max(ans, dp[n][j][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:3:
/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:82:29: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   82 |   ans = max(ans, dp[n][j][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:3:
/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:82:29: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   82 |   ans = max(ans, dp[n][j][1]);
      |                             ^
fish.cpp:84:23: error: no matching function for call to 'max(int&, long long int&)'
   84 |  ans = max(ans, dp1[n]);
      |                       ^
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: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:84:23: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   84 |  ans = max(ans, dp1[n]);
      |                       ^
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: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:84:23: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   84 |  ans = max(ans, dp1[n]);
      |                       ^
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:3:
/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:84:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   84 |  ans = max(ans, dp1[n]);
      |                       ^
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:3:
/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:84:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   84 |  ans = max(ans, dp1[n]);
      |                       ^
fish.cpp:85:23: error: no matching function for call to 'max(int&, long long int&)'
   85 |  ans = max(ans, dp2[n]);
      |                       ^
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: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:85:23: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   85 |  ans = max(ans, dp2[n]);
      |                       ^
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: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:85:23: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   85 |  ans = max(ans, dp2[n]);
      |                       ^
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:3:
/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:85:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   85 |  ans = max(ans, dp2[n]);
      |                       ^
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:3:
/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:85:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   85 |  ans = max(ans, dp2[n]);
      |                       ^