# TOPIC

I have 25% WA please, help me to understand why :(

#### Ulises García asked 1 year ago

include <bits/stdc++.h> define MAXN 105

using namespace std;

string A[MAXN]; int M[MAXN][MAXN];

int n, m;

bool ban = false; int deltaX[] = {1, -1, 0, 0}; int deltaY[] = {0, 0, 1, -1};

bool checar(int x, int y){ if(x>=0 && x<n && y>=0 && y<m) return true; return false; }

bool DFS(int i, int j, int dir){ if(A[i][j]=='*') return true; if(A[i][j]=='v') dir=0; if(A[i][j]=='^') dir=1; if(A[i][j]=='>') dir=2; if(A[i][j]=='<') dir=3; if(M[i][j] == dir){ return false; } M[i][j] = dir;

```if(dir!=-1){
if(checar(i+deltaX[dir], j+deltaY[dir])){
DFS(i+deltaX[dir], j+deltaY[dir], dir);
}
}
return false;```

}

int main(){ cin >> m >> n; for(int i=0; i<n; i++){ cin >> A[i]; }

```memset(M, -1, sizeof(M));
bool ban = DFS(0, 0, -1);

if(ban) cout << "*\n";
else cout << "!\n";
return 0;```

}

This topic has not been answered yet. Be the first!

Remember not post solutions. Your post may be reviewed by our moderators.