Language: C++

//OPTIMIZATONS
#pragma GCC optimize("02")
//CODE
#include<bits/stdc++.h>
#define int unsigned long long
#define float double
#define endl "\n"
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

using namespace std;
const int N = 11;
int n,m,q;

int pts[N][N][N];
int dp[N][N];
bool visit[N][N];

int solve(int x,int y,vector<int> value){
	if(x>=n) return 0;
	if(visit[x][y]) return dp[x][y];
	visit[x][y] = true;
	int ans = 0;
	for(int i=0;i<value.size();i++){
		ans += pts[x][i][y-value[i]];
	}
	value.push_back(y);
	int res = 0;
	for(int i=y;i<=m;i++){
		res = max(res,solve(x+1,i,value));
	}
	dp[x][y] = ans + res;
	return dp[x][y];
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//CODE FOR SPECIFIED INPUT AND OUTPUT
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>m>>q;
	memset(pts,0,sizeof(pts));
	memset(visit,0,sizeof(visit));
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<q;i++){
		int a,b,c;
		cin>>a>>b>>c;
		a--; b--;
		cin>>pts[b][a][c];
	}
	int ans = 0;
	for(int i=1;i<=m;i++){
		vector<int> temp;
		ans = max(ans,solve(0,i,temp));
	}
	cout<<ans<<endl;
	return 0;
}



Compiler output:
a.cc: In function 'long long unsigned int solve(long long unsigned int, long long unsigned int, std::vector<long long unsigned int>)':
a.cc:21:12: error: reference to 'visit' is ambiguous
   21 |         if(visit[x][y]) return dp[x][y];
      |            ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:4:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:17:6: note:                 'bool visit [11][11]'
   17 | bool visit[N][N];
      |      ^~~~~
a.cc:22:9: error: reference to 'visit' is ambiguous
   22 |         visit[x][y] = true;
      |         ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:17:6: note:                 'bool visit [11][11]'
   17 | bool visit[N][N];
      |      ^~~~~
a.cc: In function 'int32_t main()':
a.cc:44:16: error: reference to 'visit' is ambiguous
   44 |         memset(visit,0,sizeof(visit));
      |                ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:17:6: note:                 'bool visit [11][11]'
   17 | bool visit[N][N];
      |      ^~~~~
a.cc:44:31: error: reference to 'visit' is ambiguous
   44 |         memset(visit,0,sizeof(visit));
      |                               ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:17:6: note:                 'bool visit [11][11]'
   17 | bool visit[N][N];
      |      ^~~~~