Submission #470307

# Submission time Handle Problem Language Result Execution time Memory
470307 2021-09-03T12:58:24 Z mychecksedad Patkice (COCI20_patkice) C++17
0 / 50
0 ms 204 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
const int N = 110, F = 1e9+7;


int n, m, sx, sy;
char c, cc[4] = {'>', '<', '^', 'v'}, arr[N][N];
int dfs(int x, int y){
	if(x == 0 || x == n + 1 || y == 0 || y == m + 1 || arr[x][y] == '.') return F;
	if(arr[x][y] == 'x') return 1;
	int ans = 0;
	if(arr[x][y] == '>'){
		ans = dfs(x, y + 1);
	}
	if(arr[x][y] == '<'){	
		ans = dfs(x, y - 1);
	}
	if(arr[x][y] == '^'){
		ans = dfs(x - 1, y);
	}
	if(arr[x][y] == 'v'){
		ans = dfs(x + 1, y);
	}
	return min(ans + 1, F);
}
int main(){
	cin.tie(0); ios::sync_with_stdio(0);
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			cin >> arr[i][j];
			if(arr[i][j] == 'o'){
				sx = i, sy = j;
			}
		}
	}
	int ans1 = dfs(sx, sy + 1);
	int ans2 = dfs(sx, sy - 1);
	int ans3 = dfs(sx - 1, sy);
	int ans4 = dfs(sx + 1, sy);
	int r = min({ans1, ans2, ans3, ans4});
	if(r==F){
		cout << ":(";
	}else{
		cout << ":)\n";
		if(r == ans1) cout << "E";
		else if(r == ans2) cout << "W";
		else if(r == ans3) cout << "N";
		else if(r == ans4) cout << "S";
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -