Submission #480915

# Submission time Handle Problem Language Result Execution time Memory
480915 2021-10-18T17:54:05 Z CSQ31 Patkice (COCI20_patkice) C++17
50 / 50
1 ms 224 KB
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) (int)(a.size())
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(998244353)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
char g[200][200];
int dist[200][200];
char c[4] = {'E','N','S','W'};
int dy[4] = {1,0,0,-1};
int dx[4] = {0,-1,1,0};
int r,s;
int main()
{
	cin>>r>>s;
	int sx,sy,tx,ty;
	sx = sy = tx = ty = 0;
	for(int i=0;i<r;i++){
		for(int j=0;j<s;j++){
			cin>>g[i][j];
			if(g[i][j] == 'o'){
				sx = i;
				sy = j;	
			}
			if(g[i][j] == 'x'){
				tx = i;
				ty = j;
			}
		}
	}
	int ans = 1e9;
	char f = 'Z';
	for(int i=0;i<4;i++){
		int x = sx+dx[i];
		int y = sy+dy[i];
		int d = 0;
		while(true){
			if(g[x][y] == 'o' || g[x][y] == '.' || g[x][y] == 'x')break;
			if(g[x][y] == '^')x--;
			else if(g[x][y] == 'v')x++;
			else if(g[x][y] == '>')y++;
			else y--;
			d++;
		}
		if(g[x][y] == 'x' && ans > d){
			ans = d;
			f = c[i];
		}
			
	}
	if(ans == 1e9)cout<<":("<<'\n';
	else{
		cout<<":)"<<'\n';
		cout<<f<<'\n';
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 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 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 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 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 204 KB Output is correct
11 Correct 1 ms 204 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 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 224 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct