Submission #447592

#TimeUsernameProblemLanguageResultExecution timeMemory
447592MahfuzAhmedPatkice (COCI20_patkice)C++14
Compilation error
0 ms0 KiB
/** * author: mahfuzz * created: 27.07.2021 **/ #include <bits/stdc++.h> using namespace std; #define trace(x) cerr << '>' << #x << ':' << x << endl; #define all(p) p.begin(),p.end() typedef long long ll; const int maxn = 110; char grid[maxn][maxn]; bool mark[maxn][maxn]; int r, c; bool flag = false; int cnt = 0; void dfs(int x, int y){ ++cnt; if(mark[x][y] || x < 0 || x > r || y < 0 || y > c) return; mark[x][y] = 1; if(grid[x][y] == 'x'){ flag = true; return; } if(grid[x][y] == '<') dfs(x, y - 1); else if(grid[x][y] == '>') dfs(x, y + 1); else if(grid[x][y] == 'v') dfs(x + 1, y); else if(grid[x][y] == '^') dfs(x - 1, y); else return; } int main(int argc, char* argv[]){ ios_base::sync_with_stdio(0); cin.tie(nullptr); cin >> r >> c; int ox, oy; for(int i = 0; i < r; i++){ for(int j = 0; j < c; j++){ cin >> grid[i][j]; if(grid[i][j] == 'o') ox = i, oy = j; if(grid[i][j] == 'x') xx = i, xy = j; } } vector<pair<char, int>> vec; dfs(ox, oy + 1); if(flag) vec.push_back({'E', cnt}); cnt = 0; flag = false; for(int i = 0; i < r; i++) memset(mark[i], 0, sizeof(mark[i])); dfs(ox - 1, oy); if(flag) vec.push_back({'N', cnt}); cnt = 0; flag = false; for(int i = 0; i < r; i++) memset(mark[i], 0, sizeof(mark[i])); dfs(ox + 1, oy); if(flag) vec.push_back({'S', cnt}); cnt = 0; flag = false; for(int i = 0; i < r; i++) memset(mark[i], 0, sizeof(mark[i])); dfs(ox, oy - 1); if(flag) vec.push_back({'W', cnt}); cnt = 0; flag = false; for(int i = 0; i < r; i++) memset(mark[i], 0, sizeof(mark[i])); sort(all(vec), [&](pair<char, int> x, pair<char, int> y){ if(x.second < y.second) return true; else if(x.second == y.second) if(x.first < y.first) return true; return false; }); if(vec.size()){ cout << ":)\n"; cout << vec[0].first << "\n"; }else{ cout << ":(\n"; } return 0; }

Compilation message (stderr)

patkice.cpp: In function 'int main(int, char**)':
patkice.cpp:59:17: error: 'xx' was not declared in this scope; did you mean 'ox'?
   59 |                 xx = i, xy = j;
      |                 ^~
      |                 ox
patkice.cpp:59:25: error: 'xy' was not declared in this scope; did you mean 'oy'?
   59 |                 xx = i, xy = j;
      |                         ^~
      |                         oy