求助,编译失败!

P1649 [USACO07OCT] Obstacle Course S

FatFairy @ 2021-07-22 09:15:10

#include <iostream>
#include <cstring>
using namespace std;
const int maxn = 105;
char s[maxn][maxn];
int x1,y1,x2,y2,n,ans = 65535;
bool vis[maxn][maxn];
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
void solve(int x,int y,int ob,int j){
    if((x>n||x<1)||(y>n||y<1)||s[x][y] == 'x'||vis[x][y])   return;
    if(ob > ans)    return;
    if(x == x2 && y == y2){
        ans = min(ans,ob);
        return;
    }
    vis[x][y] = true;
    for(int i=0;i<4;i++){
        int nx = x + dx[i],ny = y + dy[i];
        if(j == 0){
            solve(nx,ny,ob,i+1);
        }
        else{
            if(i+1 == j){
                solve(nx,ny,ob,i+1);
            }
            else{
                solve(nx,ny,ob+1,i+1);
            }
        }
    }
    vis[x][y] = false;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            cin>>s[i][j];
            if(s[i][j] == 'A'){
                x1 = i;
                y1 = j;
            }
            else if(s[i][j] == 'B'){
                x2 = i;
                y2 = j;
            }
        }
    }
    memset(vis,false,sizeof(vis));
    solve(x1,y1,0,0);
    if(ans != 65535) cout<<ans;
    else cout<<"-1";
    return 0;
 } 

by 名字好难取144 @ 2021-07-22 09:16:36

可能是评测机炸了。。。


by 名字好难取144 @ 2021-07-22 09:17:20

问就是a+b problem原ac代码也编译错误


by μηδσ @ 2021-07-22 09:20:05

别急,评测机炸了,等会再交试试


|