QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#141481#6534. Peg Solitairecy1999RE 0ms0kbC++17941b2023-08-17 14:57:452023-08-17 14:57:45

Judging History

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

  • [2023-08-17 14:57:45]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-08-17 14:57:45]
  • 提交

answer

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

int mp[10][10];
int n,m,k,ans;

int tiao(int res){
//	P now=find();
	ans=min(ans,res);
	for(int x=1;x<=n;x++){
		for(int y=1;y<=m;y++){
			if(!mp[x][y]) continue;
			mp[x][y]=0;
			if(x+2<=n&&mp[x+1][y]&&!mp[x+2][y]){
				mp[x+1][y]=0;mp[x+2][y]=1;
				tiao(res-1);
				mp[x+1][y]=1;mp[x+2][y]=0;
				
			}
			if(y-2>=1&&mp[x][y-1]&&!mp[x][y-2]){
				mp[x][y-1]=0;mp[x][y-2]=1;
				tiao(res-1);
				mp[x][y-1]=1;mp[x][y-2]=0;
			
			}
			if(y+2<=m&&mp[x][y+1]&&!mp[x][y+2]){
				mp[x][y+1]=0;mp[x][y+2]=1;
				tiao(res-1);
				mp[x][y+1]=1;mp[x][y+2]=0;
			
			}
			mp[x][y]=1;
		}
	}

	
}

int main(){
	int t;cin>>t;
	while(t--){
		cin>>n>>m>>k;
		ans=1e9;
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++) mp[i][j]=0;
		}
		for(int i=1;i<=k;i++){
			int x,y;cin>>x>>y;
			mp[x][y]=1;
		}
		tiao(k);
		cout<<ans<<endl;
	}
	
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

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:


result: