样例没过查不出错

P1508 Likecloud-吃、吃、吃

@[你来看此花时](/space/show?uid=131273) 思路上没错,但是memset不能这样赋值把-9999改成0xcf。顺便%一下巨佬syh
by lygmh @ 2019-10-13 07:53:09


``` f[i][j]=max(max(f[i-1][j],f[j-1][j-1]),f[i-1][j+1])+a[i][j]; ``` i写成了j??
by HelloWorldZTR @ 2019-10-13 07:54:44


``` #include<bits/stdc++.h> #define int long long using namespace std; int n,m,x,y; int a[210][210],f[210][210]; inline int read(){ int x=0,f=1;char ch=getchar(); while(!isdigit(ch)) f=(ch=='-')?-1:1,ch=getchar(); while(isdigit(ch)) x=x*10+(ch-'0'),ch=getchar(); return x*f; } signed main(){ freopen("test.in", "r", stdin); n=read(),m=read(); x=n,y=m/2+1; memset(a,-9999,sizeof(a)); for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) a[i][j]=read(); for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) f[i][j]=max(max(f[i-1][j],f[i-1][j-1]),f[i-1][j+1])+a[i][j]; cout<<max(max(f[x][y],f[x][y-1]),f[x][y+1]); return 0; } ``` AC了[评测结果](https://www.luogu.org/record/25110608)
by HelloWorldZTR @ 2019-10-13 07:58:17


@[HelloWorldZTR](/space/show?uid=219486) 感谢巨佬!!!
by FallacyMaker @ 2019-10-13 14:37:19


|