弱弱的问一句,这一大堆宏定义是什么鬼啊?
by Zirnc @ 2019-05-11 12:11:56
全套编译优化
by Uniecho1 @ 2019-05-11 12:18:54
@[秦岭秋风](/space/show?uid=109396)
开O2可AC
```cpp
#include<bits/stdc++.h>
using namespace std;
inline int abs(int x)
{
return x>0?x:-x;
}
int N,M,K,G[801][801],f[801][801][16][2],sta,ans;
const int mod=1000000007;
inline int dfs(int x,int y,int a,int u)
{
if((x^y^sta)&1)
{
a=a+G[x][y];
if(a>=K)a-=K;
}
else
{
u=u+G[x][y];
if(u>=K)u-=K;
}
int &ret=f[x][y][abs(a-u)][a>u];
if(~ret)return ret;
if(a^u|((x^y^sta)&1^1))ret=0;
else ret=1;
if(x<N)ret=(ret+dfs(x+1,y,a,u));
if(y<M)ret=(ret+dfs(x,y+1,a,u));
if(ret>=mod)ret-=mod;
return ret;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("testdata.in","r",stdin);
#endif
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>N>>M>>K;K++;
for(int i=1;i<=N;i++)
for(int j=1;j<=M;j++)
cin>>G[i][j];
for(;sta<=1;sta++)
{
memset(f,-1,sizeof(f));
for(int i=1;i<=N;i++)
for(int j=1;j<=M;j++)
if((i^j)&1^1^sta)
{
ans=ans+dfs(i,j,0,0);
if(ans>=mod)ans-=mod;
}
}
cout<<ans<<endl;
return 0;
}
```
by Smile_Cindy @ 2019-05-11 13:29:45
@[Alpha](/space/show?uid=87058) %%%%%%
by Uniecho1 @ 2019-05-12 16:05:00