有没有大佬帮忙一下

P1002 [NOIP2002 普及组] 过河卒

输出的不是0就是-1
by 大米爱干饭 @ 2022-12-13 18:20:08


```cpp int dx[]={2,2,1,-1,-2,-2,-1,1}, dy[]={-1,1,2,2,1,-1,-2,-2}; for(int i=0;i<8;i++) if(check(horse.x+dx[i],horse.y+dy[i])) A[horse.x+dx[i]][horse.y+dy[i]]=-1; ``` 简洁方便。 ```cpp bool check(int x,int y){ return x<0||x>=n||y<0||y>=n; } ``` 还有你的: ```cpp for(int i=0;i<=4;i++) for(int j=0;j<=8;j++) //...... ``` $m,n$ 不是固定的。
by diamond_153 @ 2022-12-13 19:20:27


|