QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#394055#6534. Peg SolitaireDDTWA 0ms3684kbC++231.5kb2024-04-19 22:09:032024-04-19 22:09:03

Judging History

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

  • [2024-04-19 22:09:03]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3684kb
  • [2024-04-19 22:09:03]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f;
#define endl '\n'
#define x first
#define y second
typedef long long ll;
typedef pair<int,int> PII;
bool book[20][20];
int ans;
void dfs(int n,int m,int k)
{
	ans=min(k,ans);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(book[i][j] && book[i+1][j] && !book[i+2][j] && i+2<=n)
			{
				book[i][j]=0;
				book[i+1][j]=0;
				book[i+2][j]=1;
				dfs(n,m,k-1);
				book[i][j]=1;
				book[i+1][j]=1;
				book[i+2][j]=0;
			}
			if(book[i][j] && book[i-1][j] && !book[i-2][j] && i-2>=1)
			{
				book[i][j]=0;
				book[i-1][j]=0;
				book[i-2][j]=1;
				dfs(n,m,k-1);
				book[i][j]=1;
				book[i-1][j]=1;
				book[i-2][j]=0;
			}
			if(book[i][j] && book[i][j+1] && !book[i][j+2] && j+2<=n)
			{
				book[i][j]=0;
				book[i][j+1]=0;
				book[i][j+2]=1;
				dfs(n,m,k-1);
				book[i][j]=1;
				book[i][j+1]=1;
				book[i][j+2]=0;
			}
			if(book[i][j] && book[i][j-1] && !book[i][j-2] && j-2>=1)
			{
				book[i][j]=0;
				book[i][j-1]=0;
				book[i][j-2]=1;
				dfs(n,m,k-1);
				book[i][j]=1;
				book[i][j-1]=1;
				book[i][j-2]=0;
			}
		}
}
void solve()
{
	memset(book,0,sizeof(book));
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=1;i<=k;i++)
	{
		int x,y;
		cin>>x>>y;
		book[x][y]=1;
	}
	ans=k;
	dfs(n,m,k);
	cout<<ans<<endl;
}
int main()
{
	ios::sync_with_stdio(false);
	ios::sync_with_stdio(0);cin.tie(0),cout.tie(0);
	int t;
	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3596kb

input:

3
3 4 5
2 2
1 2
1 4
3 4
1 1
1 3 3
1 1
1 2
1 3
2 1 1
2 1

output:

2
3
1

result:

ok 3 number(s): "2 3 1"

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3684kb

input:

20
2 1 2
1 1
2 1
5 1 3
3 1
2 1
4 1
3 3 6
1 2
2 2
1 1
2 3
3 1
3 2
4 4 4
2 3
3 1
3 2
1 2
1 1 1
1 1
5 2 6
3 2
4 1
2 1
5 2
2 2
5 1
1 3 1
1 2
1 5 1
1 5
4 6 5
4 6
4 4
2 3
4 3
1 6
6 6 3
2 4
1 3
2 1
2 2 2
2 1
1 1
5 3 4
2 2
5 1
4 3
3 2
6 5 6
5 5
6 5
2 4
2 1
3 4
1 4
2 6 5
1 6
2 1
1 4
2 3
1 3
3 5 6
2 1
3 3
1 5...

output:

2
2
3
1
1
2
1
1
4
3
2
1
3
4
2
1
3
1
2
2

result:

wrong answer 9th numbers differ - expected: '3', found: '4'