Submission #707479

# Submission time Handle Problem Language Result Execution time Memory
707479 2023-03-09T05:10:38 Z GudStonks Patkice (COCI20_patkice) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ft first
#define sd second
int n, m;
char ch[105][105];
pair<ll, ll>s;
const int dirx[4] = {0, 1, 0, -1};
const int diry[4] = {1, 0, -1, 0};

int dfs(int x, int y){
	if(ch[x][y] == '.' || ch[x][y] == 'o')return 2e9;
	if(ch[x][y] == 'x')return 1;
	if(ch[x][y] == '^')return dfs(x - 1, y) + 1;
	if(ch[x][y] == 'v')return dfs(x + 1, y) + 1;
	if(ch[x][y] == '>')return dfs(x, y + 1) + 1;
	if(ch[x][y] == '<')return dfs(x, y - 1) + 1;
	return 2e9;
}

void fun(){
	cin>>n>>m;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			cin>>ch[i][j];
			if(ch[i][j] == 'o')
				s = {i, j};
		}
	}
	int cur, mn = 2e9;
	char ans = '!';
	for(int i = 0; i < 4; i++){
		cur = dfs(s.ft + dirx[i], s.sd + diry[i]);
		if(cur < mn){
			mn = cur;
			if(i == 0)
				ans = 'E';
			else if(i == 1)
				ans = 'S';
			else if(i == 2)
				ans = 'W';
			else
				ans = 'N';
		}
	}
	if(ans == '!')
		cout<<":(\n";
	else
		cout<<":)\n"<<ans;
}

signed  main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int ttt = 1;
	//cin>>ttt;
	while(ttt--)fun();
}

Compilation message

patkice.cpp:9:6: error: 'll' was not declared in this scope; did you mean 'ld'?
    9 | pair<ll, ll>s;
      |      ^~
      |      ld
patkice.cpp:9:10: error: 'll' was not declared in this scope; did you mean 'ld'?
    9 | pair<ll, ll>s;
      |          ^~
      |          ld
patkice.cpp:9:12: error: template argument 1 is invalid
    9 | pair<ll, ll>s;
      |            ^
patkice.cpp:9:12: error: template argument 2 is invalid
patkice.cpp: In function 'void fun()':
patkice.cpp:29:14: error: cannot convert '<brace-enclosed initializer list>' to 'int' in assignment
   29 |     s = {i, j};
      |              ^
patkice.cpp:5:12: error: request for member 'first' in 's', which is of non-class type 'int'
    5 | #define ft first
      |            ^~~~~
patkice.cpp:35:15: note: in expansion of macro 'ft'
   35 |   cur = dfs(s.ft + dirx[i], s.sd + diry[i]);
      |               ^~
patkice.cpp:6:12: error: request for member 'second' in 's', which is of non-class type 'int'
    6 | #define sd second
      |            ^~~~~~
patkice.cpp:35:31: note: in expansion of macro 'sd'
   35 |   cur = dfs(s.ft + dirx[i], s.sd + diry[i]);
      |                               ^~