Submission #693144

#TimeUsernameProblemLanguageResultExecution timeMemory
693144dozerPatkice (COCI20_patkice)C++14
50 / 50
1 ms724 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...