30分求助
查看原帖
30分求助
713437
chou_chou楼主2023/10/20 13:58

NO!!!

#include<bits/stdc++.h>
using namespace std;
int a,b;
int m[55][55];
int ans=0;
int maxx=0;
void f(int x,int y,int x1,int y1){
	if(x>a||y>b||x1>a||y1>b){
		return ;
	}
	if(x==a&&y==b&&x1==a&&y1==b){
		maxx=max(maxx,ans);
		//cout<<ans<<endl;
		return ;
	}
	if(x==x1&&y==y1&&!(x==1&&y==1&&x1==1&&y1==1)){
		return ;
	}
	ans+=m[x][y]+m[x1][y1];
	f(x+1,y,x1+1,y1);
	f(x+1,y,x1,y1+1);
	f(x,y+1,x1+1,y1);
	f(x,y+1,x1,y1+1);
	ans-=m[x][y]+m[x1][y1];
	return ;
}
int main(){
	cin>>a>>b;
	for(int i=1;i<=a;i++){
		for(int j=1;j<=b;j++){
			cin>>m[i][j];
		}
	}
	f(1,1,1,1);
	cout<<maxx;
	return 0;
}
2023/10/20 13:58
加载中...