这就是一道滑雪嘛= =
所有操作都爆力,求路径就dp,完了
CODE:
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define maxn 710
#define inf 0x7fffffff
bool bo[maxn][maxn],b[maxn][maxn];
int f[maxn][maxn],a[maxn][maxn];
int way[4][2]={{1,0},{-1,0},{0,-1},{0,1}};
int dfs(int x,int y){
if (bo[x][y]||b[x][y]) return f[x][y];
int ans=0;
bo[x][y]=1;
for (int i=0;i<4;i++)
if (a[x][y]>a[x+way[i][0]][y+way[i][1]])
ans=max(dfs(x+way[i][0],y+way[i][1]),ans);
ans++;
f[x][y]=ans;
return ans;
}
char s[2];
int main(){
int n,m;
scanf("%d",&n);
for (int i=1;i<=n;i++)
for (int j=1;j<=n;j++) scanf("%d",&a[i][j]);
for (int i=1;i<=n;i++) a[i][0]=a[0][i]=a[i][n+1]=a[n+1][i]=inf;
scanf("%d",&m);
while (m--){
scanf("%s",s);
int x1,y1,x2,y2,x;
if (s[0]=='C'){
scanf("%d%d%d",&x1,&y1,&x);
a[x1][y1]=x;
}
if (s[0]=='S'){
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
for (int i=x1;i<=x2;i++)
for (int j=y1;j<=y2;j++) b[i][j]=1;
}
if (s[0]=='B'){
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
for (int i=x1;i<=x2;i++)
for (int j=y1;j<=y2;j++) b[i][j]=0;
}
if (s[0]=='Q'){
memset(bo,0,sizeof(bo));
memset(f,0,sizeof(f));
int ans=0;
for (int i=1;i<=n;i++)
for (int j=1;j<=n;j++)
ans=max(ans,dfs(i,j));
printf("%d\n",ans);
}
}
return 0;
}