两侧同时换到之前的修订记录 前一修订版 | |||
2020-2021:teams:bigbros:jerydeak:sps1 [2020/05/17 20:20] jerydeak |
2020-2021:teams:bigbros:jerydeak:sps1 [2020/05/17 20:21] (当前版本) jerydeak |
||
---|---|---|---|
行 102: | 行 102: | ||
int ansf(int step,int x1,int x2){ | int ansf(int step,int x1,int x2){ | ||
- | //printf("\nCall:step=%d,x1=%d,x2=%d;\n",step,x1,x2); | ||
if(step==0)return map[0][0]; | if(step==0)return map[0][0]; | ||
if(ansflag[step][x1][x2]>0){ | if(ansflag[step][x1][x2]>0){ | ||
行 116: | 行 115: | ||
if(y1>0 && y2>0 && x1!=x2) temp=max(temp,ansf(step-1,x1,x2)); | if(y1>0 && y2>0 && x1!=x2) temp=max(temp,ansf(step-1,x1,x2)); | ||
- | //printf("\nPoint 1:step=%d,x1=%d,x2=%d;temp=%d;map1=%d,map2=%d;\n",step,x1,x2,temp,map[x1][y1],map[x2][y2]); | ||
ans[step][x1][x2]=temp+map[y1][x1]+map[y2][x2];//*condition(x1==x2,0,1); | ans[step][x1][x2]=temp+map[y1][x1]+map[y2][x2];//*condition(x1==x2,0,1); | ||
ansflag[step][x1][x2]=1; | ansflag[step][x1][x2]=1; | ||
- | //printf("\nAfter calculating:step=%d,x1=%d,x2=%d;Value=%d;\n",step,x1,x2,ans[step][x1][x2]); | ||
return ans[step][x1][x2]; | return ans[step][x1][x2]; | ||
} | } | ||
行 135: | 行 132: | ||
for(int j=0;j<n;j++) | for(int j=0;j<n;j++) | ||
scanf("%d",&map[i][j]); | scanf("%d",&map[i][j]); | ||
- | |||
- | /* | ||
- | printf("\n"); | ||
- | for(int i=0;i<m;i++){ | ||
- | for(int j=0;j<n;j++){ | ||
- | printf("%d ",map[i][j]); | ||
- | } | ||
- | printf("\n"); | ||
- | }printf("\n"); | ||
- | */ | ||
printf("%d",ansf(m+n-2,n-1,n-1)); | printf("%d",ansf(m+n-2,n-1,n-1)); | ||
- | /* | + | |
- | for(int step=0;step<m+n-1;step++){ | + | |
- | printf("\n-----\nStep=%d:\n",step); | + | |
- | for(int x1=0;x1<n;x1++){ | + | |
- | printf("\n"); | + | |
- | for(int x2=0;x2<n;x2++){ | + | |
- | printf("%d ",ans[step][x1][x2]); | + | |
- | } | + | |
- | } | + | |
- | } | + | |
- | */ | + | |
- | /* | + | |
- | while(true){ | + | |
- | printf("\n--------------\n"); | + | |
- | char c; | + | |
- | scanf("%c",&c); | + | |
- | if(c=='a'){ | + | |
- | int step,x1,x2; | + | |
- | scanf("%d%d%d",&step,&x1,&x2); | + | |
- | //printf("%d\n",ansf(step,x1,x2)); | + | |
- | printf("%d\n",ans[step][x1][x2]); | + | |
- | printf("\n--------------\n"); | + | |
- | } | + | |
- | else if(c=='m'){ | + | |
- | int x,y; | + | |
- | scanf("%d%d",&x,&y); | + | |
- | printf("%d\n",map[x][y]); | + | |
- | printf("\n--------------\n"); | + | |
- | + | ||
- | } | + | |
- | }*/ | + | |
} | } | ||
</codedoc> | </codedoc> | ||
</hidden> | </hidden> |