为啥?人性扭曲?道德沦丧??
查看原帖
为啥?人性扭曲?道德沦丧??
311502
逸之为一楼主2021/8/23 17:05

这题我爆肝了几小时,

虽然样例都没过

但是我真的找了半天BUG!

不知讨论区里有木有大佬可以帮帮窝

代码

#include<bits/stdc++.h>
using namespace std;
const int INF = 0 , INT = 1 , MAXS = 100;
int N,M,T;
long long ANS;
int A[MAXS][MAXS];
bool VIS[MAXS][MAXS];
void DFS(int X,int Y,long long SUM){
//	cout<<"  "<<SUM<<endl;
	if(Y==M+INT){ DFS(X+INT , INT , SUM);return ;}
	if(X==N+INT) {ANS=max(ANS,SUM);return ;}
//	cout<<X<<' '<<Y<<endl; 
	if(VIS[X-1][Y-1]==true && VIS[X-1][Y]==true && VIS[X-1][Y+1]==true && VIS[X][Y-1]==true && VIS[X][Y+1]==true && VIS[X+1][Y-1]==true && VIS[X+1][Y]==true && VIS[X+1][Y+1]==true){
		VIS[X][Y]=false;
		DFS(X,Y+INT,SUM+A[X][Y]);
		VIS[X][Y]=true; 
	}DFS(X,Y+INT,SUM);
}int main(){ 
	cin>>T;
	while(T--){
		ANS=INF;
		cin>>N>>M;
		for(int i=INT;i<=N;i++) for(int l=INT;l<=M;l++){cin>>A[i][l];VIS[i][l]=true;} 
		DFS( INT , INT , INF);
		printf ( "%lld\n" , ANS);
	}return 0;
}
2021/8/23 17:05
加载中...