吸吸空气试试
by 哔哩哔哩 @ 2018-11-07 11:41:26
玄学卡时怒艹60
```cpp
#include<bits/stdc++.h>
using namespace std;
const long long dx[10]={0,1,1,-1,0,0,1,-1,-1};
const long long dy[10]={0,-1,0,0,-1,1,1,-1,1};
long long N,M,X[105][105],MINN=2e9,f[105][105][10],TIM=0;
inline void dfs(long long x,long long y,long long ans,long long las)
{
TIM++;
if (TIM>100000000) return;
if (x<1||x>N||y<1||y>M) return;
if (x==N&&y==M)
{
MINN=min(MINN,ans);
return;
}
if (f[x][y][las]<=ans) return;
f[x][y][las]=ans;
for (int i=1;i<=8;i++)
{
if (i==las) continue;
dfs(x+dx[i]*X[x][y],y+dy[i]*X[x][y],ans+1,i);
}
}
int main()
{
memset(f,0x3f,sizeof(f));
scanf("%lld%lld",&M,&N);
for (int i=1;i<=N;i++) for (int j=1;j<=M;j++) scanf("%lld",&X[i][j]);
dfs(1,1,0,0);
if (MINN!=2e9) cout<<MINN<<endl;else cout<<"NEVER"<<endl;
return 0;
}
```
by Episode9 @ 2018-11-07 11:43:11
@[void_basic_learner](/user/219595) 我来考你的古
by Episode9 @ 2020-05-26 20:13:01
@[Voidstruct](/user/37409) 你怎么这么菜啊
by Episode9 @ 2020-05-26 20:13:28