Submission #482079

#TimeUsernameProblemLanguageResultExecution timeMemory
482079s_samchenkoPatkice (COCI20_patkice)C++17
50 / 50
5 ms6604 KiB
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #define ll long long #define ff first #define ss second #define int ll #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define pb push_back #define pii pair <int, int> using namespace std; const int inf = 1e15; const int mod = 1e9+7; const int N = 2e5+100; int n, m; vector < string > a(N); int dfs(int x, int y, int d = 0){ if (a[x][y] == 'o' || a[x][y] == 'x' || a[x][y] == '.'){ if (a[x][y] == 'x') return d; return inf; } if (a[x][y] == '>') return dfs(x, y+1, d+1); if (a[x][y] == '<') return dfs(x, y-1, d+1); if (a[x][y] == '^') return dfs(x-1, y, d+1); if (a[x][y] == 'v') return dfs(x+1, y, d+1); } void solve(){ cin >> n >> m; for (int i = 0; i < n; ++i) cin >> a[i]; pii start; for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) if (a[i][j] == 'o') start = {i, j}; vector <int> ans(4, inf); ans[0] = dfs(start.ff, start.ss+1); ans[3] = dfs(start.ff, start.ss-1); ans[1] = dfs(start.ff-1, start.ss); ans[2] = dfs(start.ff+1, start.ss); int mx = *min_element(all(ans)); if (mx == inf){ cout << ":("; return; } cout << ":)\n"; if (ans[0] == mx) cout << "E"; else if (ans[1] == mx) cout << "N"; else if (ans[2] == mx) cout << "S"; else cout << "W"; } signed main(){ ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int tt = 1; //cin >> tt; while (tt--){ solve(); cout << '\n'; } }

Compilation message (stderr)

patkice.cpp: In function 'long long int dfs(long long int, long long int, long long int)':
patkice.cpp:28:1: warning: control reaches end of non-void function [-Wreturn-type]
   28 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...