正文
增加 9 行删除 9 行
27 行未改动28293031323334353637383940413 行未改动4546474849505152536 行未改动606162636465666768697071727374757677787980818283848586878889909192938 行未改动27 行未改动hx[]={0,-1,-1,0,0,1,1,0},hy[]={1,0,0,-1,-1,0,0,1};ll f[N][N][2][2];bool h[N][N],e[N][N];int n,m;void dp(int i,int j,int x1,int x2,int x3,int x4,int x5,int x6,int x7,int x8){f[i][j][0][0]=(f[i-1][j][0][0]*x1+f[i-1][j][1][0]*x5)%P;f[i][j][1][0]=(f[i-1][j][0][1]*x2+f[i-1][j][1][1]*x6)%P;f[i][j][0][1]=(f[i][j-1][0][0]*x3+f[i][j-1][1][0]*x7)%P;f[i][j][1][1]=(f[i][j-1][0][1]*x4+f[i][j-1][1][1]*x8)%P;}int main(){freopen("centrallimit.in","r",stdin);freopen("centrallimit.out","w",stdout);3 行未改动cin>>n>>m;Rep(i,1,m){int x,y;cin>>x>>y;h[x][y]=1;}Rep(x,0,n)Rep(y,0,n)if(h[x][y])Rep(d,0,5){int nx=x+dx[d],ny=y+dy[d];if(nx<0||nx>n||ny<0||ny>n) continue;6 行未改动if(!e[0][1]) f[0][1][0][1]=1;if(!e[1][0]) f[1][0][0][0]=1;if(!e[1][1]) f[1][1][1][0]=!e[0][1],f[1][1][0][1]=!e[1][0];Rep(i,2,n) if(!e[i][0]) f[i][0][0][0]=f[i-1][0][0][0];Rep(i,2,n) if(!e[0][i]) f[0][i][1][1]=(f[0][i-1][0][1]+f[0][i-1][1][1])%P;Rep(i,2,n) if(!e[i][1]){// have/not have a horsef[i][1][0][0]=(f[i-1][1][1][0]+f[i-1][1][0][0]*(h[i-2][0]?h[i-1][0]:1))%P;f[i][1][1][0]=f[i-1][1][0][1];f[i][1][0][1]=f[i][0][0][0];}Rep(i,2,n) if(!e[1][i]){// have/not have a horseif(h[0][i-2]) f[1][i][1][1]=(f[1][i-1][0][1]+f[1][i-1][1][1]*h[0][i-1])%P;else f[1][i][1][1]=(f[1][i-1][1][1]+f[1][i-1][0][1])%P;f[1][i][0][1]=f[1][i-1][1][0];f[1][i][1][0]=f[0][i][1][1];}Rep(i,2,n)Rep(j,2,n){if(h[i-1][j-2]&&h[i-2][j-1]) continue; // too many horseif(e[i][j]) continue; // be eatenif(h[i-1][j-2]){// horse leg brokenif(h[i-1][j-1]) dp(i,j,1,0,0,1,1,1,1,1);else dp(i,j,0,0,0,1,0,1,1,0);}else if(h[i-2][j-1]){// horse leg brokenif(h[i-1][j-1]) dp(i,j,1,1,1,1,1,0,0,1);else dp(i,j,0,1,1,0,1,0,0,0);}elsedp(i,j,1,1,1,1,1,1,1,1);}cout<<(8 行未改动27 行未改动28293031323334353637383940413 行未改动4546474849505152536 行未改动606162636465666768697071727374757677787980818283848586878889909192938 行未改动27 行未改动hx[]={0,-1,-1,0,0,1,1,0},hy[]={1,0,0,-1,-1,0,0,1};ll f[N][N][2][2];bool h[N][N],e[N][N];int n,m;void dp(int i,int j,int x1,int x2,int x3,int x4,int x5,int x6,int x7,int x8){f[i][j][0][0]=(f[i-1][j][0][0]*x1+f[i-1][j][1][0]*x5)%P;f[i][j][1][0]=(f[i-1][j][0][1]*x2+f[i-1][j][1][1]*x6)%P;f[i][j][0][1]=(f[i][j-1][0][0]*x3+f[i][j-1][1][0]*x7)%P;f[i][j][1][1]=(f[i][j-1][0][1]*x4+f[i][j-1][1][1]*x8)%P;}int main(){freopen("centrallimit.in","r",stdin);freopen("centrallimit.out","w",stdout);3 行未改动cin>>n>>m;Rep(i,1,m){int x,y;cin>>x>>y;h[x][y]=1;}Rep(x,0,n)Rep(y,0,n)if(h[x][y])Rep(d,0,5){int nx=x+dx[d],ny=y+dy[d];if(nx<0||nx>n||ny<0||ny>n) continue;6 行未改动if(!e[0][1]) f[0][1][0][1]=1;if(!e[1][0]) f[1][0][0][0]=1;if(!e[1][1]) f[1][1][1][0]=!e[0][1],f[1][1][0][1]=!e[1][0];Rep(i,2,n) if(!e[i][0]) f[i][0][0][0]=f[i-1][0][0][0];Rep(i,2,n) if(!e[0][i]) f[0][i][1][1]=(f[0][i-1][0][1]+f[0][i-1][1][1])%P;Rep(i,2,n) if(!e[i][1]){// have/not have a horsef[i][1][0][0]=(f[i-1][1][1][0]+f[i-1][1][0][0]*(h[i-2][0]?h[i-1][0]:1))%P;f[i][1][1][0]=f[i-1][1][0][1];f[i][1][0][1]=f[i][0][0][0];}Rep(i,2,n) if(!e[1][i]){// have/not have a horseif(h[0][i-2]) f[1][i][1][1]=(f[1][i-1][0][1]+f[1][i-1][1][1]*h[0][i-1])%P;else f[1][i][1][1]=(f[1][i-1][1][1]+f[1][i-1][0][1])%P;f[1][i][0][1]=f[1][i-1][1][0];f[1][i][1][0]=f[0][i][1][1];}Rep(i,2,n)Rep(j,2,n){if(h[i-1][j-2]&&h[i-2][j-1]) continue; // too many horseif(e[i][j]) continue; // be eatenif(h[i-1][j-2]){// horse leg brokenif(h[i-1][j-1]) dp(i,j,1,0,0,1,1,1,1,1);else dp(i,j,0,0,0,1,0,1,1,0);}else if(h[i-2][j-1]){// horse leg brokenif(h[i-1][j-1]) dp(i,j,1,1,1,1,1,0,0,1);else dp(i,j,0,1,1,0,1,0,0,0);}elsedp(i,j,1,1,1,1,1,1,1,1);}cout<<(8 行未改动