Submission #693144

# Submission time Handle Problem Language Result Execution time Memory
693144 2023-02-02T12:17:39 Z dozer Patkice (COCI20_patkice) C++14
50 / 50
1 ms 724 KB
#include <bits/stdc++.h>
using namespace std;
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define pb push_back
#define pii pair<int ,int>
#define st first
#define nd second
#define sp " "
#define endl "\n"
#define N 1005


const int INF = 1e9 + 7;
pii adj[N][N], s, t;


int dfs(int i, int j)
{
	if (i == t.st && j == t.nd) return 0;
	if (adj[i][j].st == 0 && adj[i][j].nd == 0) return INF;
	int a = adj[i][j].st, b = adj[i][j].nd;
	return dfs(i + a, j + b) + 1;
}


int32_t main()
{
	fastio();


	map<char, pii> dir;
	map<pii, char> rev;
	dir['^'] = {-1, 0}, dir['v'] = {1, 0}, dir['>'] = {0, 1}, dir['<'] = {0, -1};
	rev[{0, 1}] = 'E', rev[{0, -1}] = 'W', rev[{1, 0}] = 'S', rev[{-1, 0}] = 'N';
	int n, m;
	cin>>n>>m;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			char tmp;
			cin>>tmp;
			if(tmp == '.') continue;
			if (tmp == 'o') s = {i, j};
			else if (tmp == 'x') t = {i, j};
			else
			{
				int a = dir[tmp].st, b = dir[tmp].nd;
				adj[i][j] = dir[tmp];
			}
		}
	}
	pair<int, char> ans = {INF, ':'};
	for (auto i : rev)
	{
		int a = i.st.st, b = i.st.nd;
		ans = min(ans, {dfs(s.st + a, s.nd + b), i.nd});
	}
	if (ans.st < INF)
	{
		cout<<":)\n";
		cout<<ans.nd<<endl;
	}
	else cout<<":(\n";
	cerr<<"time taken : "<<(float)clock() / CLOCKS_PER_SEC<<" seconds\n";
}

Compilation message

patkice.cpp: In function 'int32_t main()':
patkice.cpp:49:9: warning: unused variable 'a' [-Wunused-variable]
   49 |     int a = dir[tmp].st, b = dir[tmp].nd;
      |         ^
patkice.cpp:49:26: warning: unused variable 'b' [-Wunused-variable]
   49 |     int a = dir[tmp].st, b = dir[tmp].nd;
      |                          ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 1 ms 724 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 1 ms 588 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 456 KB Output is correct
8 Correct 1 ms 584 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 724 KB Output is correct
11 Correct 1 ms 588 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct