Submission #436078

#TimeUsernameProblemLanguageResultExecution timeMemory
436078peacePatkice (COCI20_patkice)C++17
50 / 50
1 ms332 KiB
#include <bits/stdc++.h> using namespace std; const int N = 105; const int SZ = N * N; const int hi[] = {0, -1, 1, 0}; const int hj[] = {1, 0, 0, -1}; const char *cv = "ENSW"; char s[N]; int c[N][N]; int main() { map<char,int> mp; mp['>'] = 0; mp['^'] = 1; mp['v'] = 2; mp['<'] = 3; mp['o'] = -1; mp['x'] = -2; mp['.'] = -3; int n, m; scanf("%d%d", &n, &m); int src_i, src_j; for (int i = 0; i < n; i++) { scanf("%s", s); for (int j = 0; j < m; j++) { c[i][j] = mp[s[j]]; if (c[i][j] == -1) { src_i = i; src_j = j; } } } int res = -1; char res_c; for (int dr = 0; dr < 4; dr++) { int i = src_i; int j = src_j; int sz = 0; i += hi[dr]; j += hj[dr]; sz++; while (c[i][j] >= 0) { int val = c[i][j]; i += hi[val]; j += hj[val]; sz++; } if (c[i][j] != -2) continue; if (res < 0 || res > sz) { res = sz; res_c = cv[dr]; } } if (res < 0) puts(":("); else { puts(":)"); printf("%c\n", res_c); } }

Compilation message (stderr)

patkice.cpp: In function 'int main()':
patkice.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |  scanf("%d%d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~
patkice.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |   scanf("%s", s);
      |   ~~~~~^~~~~~~~~
patkice.cpp:45:5: warning: 'src_j' may be used uninitialized in this function [-Wmaybe-uninitialized]
   45 |   j += hj[dr];
      |   ~~^~~~~~~~~
patkice.cpp:44:5: warning: 'src_i' may be used uninitialized in this function [-Wmaybe-uninitialized]
   44 |   i += hi[dr];
      |   ~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...