Submission #470310

# Submission time Handle Problem Language Result Execution time Memory
470310 2021-09-03T13:03:32 Z mychecksedad Patkice (COCI20_patkice) C++17
30 / 50
1 ms 332 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 arr[N][N];
int dfs(int x, int y){
	if(x == 0 || x == n + 1 || y == 0 || y == m + 1 || arr[x][y] == '.' || arr[x][y] == 'o') 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 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Incorrect 1 ms 204 KB Output isn't correct
18 Halted 0 ms 0 KB -