Submission #851346

#TimeUsernameProblemLanguageResultExecution timeMemory
851346vjudge1Patkice (COCI20_patkice)C++98
50 / 50
1 ms600 KiB
#include <bits/stdc++.h> using namespace std; #define sp << " " << //#define int long long #define vi vector<int> #define pb push_back #define F(xxx,yyy) for (int xxx=1;xxx<=yyy;xxx++) const int N = 2e5+1; void solve() { int n,m; cin >> n >> m; char grid[n+1][m+1]; int px,py; F(i,n) { string s; cin >> s; F(j,m) { grid[i][j] = s[j-1]; if (grid[i][j] == 'o') px = i,py = j; } } vector<char> dirs = {'E','W','N','S'}; vi dx = {0,0,-1,1}; vi dy = {1,-1,0,0}; int steps = 1e9; string ans; char ans2; for (int i=0;i<4;i++) { int x = px+dx[i]; int y = py+dy[i]; if (!(x <= n && x >= 1 && y <=m && y >= 1)) continue; int haha = 0; while (grid[x][y] != '.') { haha++; if (grid[x][y] == '>') y++; else if (grid[x][y] == '<') y--; else if (grid[x][y] == '^') x--; else if (grid[x][y] == 'v') x++; else break; } if (grid[x][y] == 'x') { if (haha < steps || (haha == steps && ans2 > dirs[i])){ steps = haha; ans = ":)\n"; ans2 = dirs[i]; } } } if (ans[1] == ')') cout << ans << ans2 << endl; else cout << ":(\n"; } signed main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int t = 1; //cin >> t; while (t --> 0) solve(); }

Compilation message (stderr)

patkice.cpp: In function 'void solve()':
patkice.cpp:45:39: warning: 'ans2' may be used uninitialized in this function [-Wmaybe-uninitialized]
   45 |    if (haha < steps || (haha == steps && ans2 > dirs[i])){
      |                        ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
patkice.cpp:32:18: warning: 'px' may be used uninitialized in this function [-Wmaybe-uninitialized]
   32 |   int x = px+dx[i];
      |                  ^
patkice.cpp:33:18: warning: 'py' may be used uninitialized in this function [-Wmaybe-uninitialized]
   33 |   int y = py+dy[i];
      |                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...