QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#421601#6534. Peg Solitairesuyue7Compile Error//C++201.5kb2024-05-25 22:09:222024-05-25 22:09:22

Judging History

你现在查看的是最新测评结果

  • [2024-05-25 22:09:22]
  • 评测
  • [2024-05-25 22:09:22]
  • 提交

answer

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

int n,m,k,res;
bool visit[7][7];

void dfs(int k)
{
	res=min(res,k);
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
		{
			if (visit[i][j])  //该位置没有棋子 
			{
				if (j>=3&&visit[i][j-1]&&!visit[i][j-2])  //往左跳
				{
					visit[i][j-1]=visit[i][j]=false;
					visit[i][j-2]=true;
					dfs(k-1);
					
					visit[i][j-1]=visit[i][j]=true;
					visit[i][j-2]=false;
				}
				if (j<=m-2&&visit[i][j+1]&&!visit[i][j+2])//往右跳
				{
					visit[i][j+1]=visit[i][j]=false;
					visit[i][j+2]=true;
					dfs(k-1);
					
					visit[i][j+1]=visit[i][j]=true;
					visit[i][j+2]=false;
				}
				if (i>=3&&visit[i-1][j]&&!visit[i-2][j])//往上跳
				{
					visit[i-1][j]=visit[i][j]=false;
					visit[i-2][j]=true;
					dfs(k-1);
					
					visit[i-1][j]=visit[i][j]=true;
					visit[i-2][j]=false;
				}
				if (i<=n-2&&visit[i+1][j]&&!visit[i+2][j])//往下跳
				{
					visit[i+1][j]=visit[i][j]=false;
					visit[i+2][j]=true;
					dfs(k-1);
					
					visit[i+1][j]=visit[i][j]=true;
					visit[i+2][j]=false;
				}
			}
		}
	}
}
int main()
{
	int T;
	cin>>T;
	while (T--)
	{
		cin>>n>>m>>k;
		//vector<vector<bool>> visit(n, vector<bool>(m, false));
		memset(visit,0,sizeof(visit));
		res=k;
		for (int i=1;i<=k;i++)
		{
        	int x,y;
			cin>>x>>y;
			visit[x][y]=true;  //标记该位置有一个棋子
		}
		//dfs(k,visit);
		dfs(k);
		cout<<res<<endl;
	}
	return 0;
}

详细

answer.code: In function ‘void dfs(int)’:
answer.code:14:29: error: reference to ‘visit’ is ambiguous
   14 |                         if (visit[i][j])  //该位置没有棋子
      |                             ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:80,
                 from answer.code:1:
/usr/include/c++/13/variant:1867:5: note: candidates are: ‘template<class _Res, class _Visitor, class ... _Variants> constexpr _Res std::visit(_Visitor&&, _Variants&& ...)’
 1867 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
/usr/include/c++/13/variant:1827:5: note:                 ‘template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)’
 1827 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
answer.code:5:6: note:                 ‘bool visit [7][7]’
    5 | bool visit[7][7];
      |      ^~~~~
answer.code:16:43: error: reference to ‘visit’ is ambiguous
   16 |                                 if (j>=3&&visit[i][j-1]&&!visit[i][j-2])  //往左跳
      |                                           ^~~~~
/usr/include/c++/13/variant:1867:5: note: candidates are: ‘template<class _Res, class _Visitor, class ... _Variants> constexpr _Res std::visit(_Visitor&&, _Variants&& ...)’
 1867 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
/usr/include/c++/13/variant:1827:5: note:                 ‘template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)’
 1827 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
answer.code:5:6: note:                 ‘bool visit [7][7]’
    5 | bool visit[7][7];
      |      ^~~~~
answer.code:16:59: error: reference to ‘visit’ is ambiguous
   16 |                                 if (j>=3&&visit[i][j-1]&&!visit[i][j-2])  //往左跳
      |                                                           ^~~~~
/usr/include/c++/13/variant:1867:5: note: candidates are: ‘template<class _Res, class _Visitor, class ... _Variants> constexpr _Res std::visit(_Visitor&&, _Variants&& ...)’
 1867 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
/usr/include/c++/13/variant:1827:5: note:                 ‘template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)’
 1827 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
answer.code:5:6: note:                 ‘bool visit [7][7]’
    5 | bool visit[7][7];
      |      ^~~~~
answer.code:18:41: error: reference to ‘visit’ is ambiguous
   18 |                                         visit[i][j-1]=visit[i][j]=false;
      |                                         ^~~~~
/usr/include/c++/13/variant:1867:5: note: candidates are: ‘template<class _Res, class _Visitor, class ... _Variants> constexpr _Res std::visit(_Visitor&&, _Variants&& ...)’
 1867 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
/usr/include/c++/13/variant:1827:5: note:                 ‘template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)’
 1827 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
answer.code:5:6: note:                 ‘bool visit [7][7]’
    5 | bool visit[7][7];
      |      ^~~~~
answer.code:18:55: error: reference to ‘visit’ is ambiguous
   18 |                                         visit[i][j-1]=visit[i][j]=false;
      |                                                       ^~~~~
/usr/include/c++/13/variant:1867:5: note: candidates are: ‘template<class _Res, class _Visitor, class ... _Variants> constexpr _Res std::visit(_Visitor&&, _Variants&& ...)’
 1867 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
/usr/include/c++/13/variant:1827:5: note:                 ‘template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)’
 1827 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
answer.code:5:6: note:                 ‘bool visit [7][7]’
    5 | bool visit[7][7];
      |      ^~~~~
answer.code:19:41: error: reference to ‘visit’ is ambiguous
   19 |                                         visit[i][j-2]=true;
      |                                         ^~~~~
/usr/include/c++/13/variant:1867:5: note: candidates are: ‘template<class _Res, class _Visitor, class ... _Variants> constexpr _Res std::visit(_Visitor&&, _Variants&& ...)’
 1867 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
/usr/include/c++/13/variant:1827:5: note:                 ‘...