Submission #707488

# Submission time Handle Problem Language Result Execution time Memory
707488 2023-03-09T05:35:53 Z GudStonks Patkice (COCI20_patkice) C++17
0 / 50
1 ms 212 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, x, y;
char ch[105][105];
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;
}

void fun(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    bool ok=false;
    char c='h';
    int mn=INT_MAX;
    cin>>n>>m;
    int x=0,y=0;
    for (int i=1;i<=n;i++){
        for (int j=1;j<=m;j++){
            cin>>ch[i][j];
            if (ch[i][j]=='o'){
                x=i;
                y=j;
            }
        }
    }
    for (int i=0;i<4;i++){
        int d=dfs(x+dirx[i],y+diry[i]);
        if (d<0) continue;
        ok=true;
        if (d<mn){
            mn=d;
            if (i==0) c='E';
            if (i==1) c='N';
            if (i==2) c='S';
            if (i==3) c='W';
        }
    }
    if (ok) cout<<":)"<<endl<<c<<endl;
    else cout<<":("<<endl;
}

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: In function 'long long int dfs(long long int, long long int)':
patkice.cpp:19:1: warning: control reaches end of non-void function [-Wreturn-type]
   19 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -