Submission #11595968
Source Code Expand
#include <bits/stdc++.h> using namespace std; using vi = vector<char>; using vvi = vector<vi>; int N, M; vvi field; using vib = vector<bool>; using vvib = vector<vib>; vvib seen; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; void dfs(int h, int w) { seen.at(h).at(w) = true; for (int dir = 0; dir < 4; ++dir) { int nh = h + dx[dir]; int nw = w + dy[dir]; if (nh < 0 || nh >= N || nw < 0 || nw >= M) continue; if (field.at(nh).at(nw) == '#') continue; if (seen.at(nh).at(nw)) continue; dfs(nh, nw); } } int main(){ int sx, sy, gx, gy; cin >> N >> M; for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { cin >> field.at(i).at(j); } } for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { if(field.at(i).at(j) == 's'){ sx = i; sy = j; } if(field.at(i).at(j) == 'g'){ gx = i; gy = j; } } } memset(seen, 0, sizeof(seen)); dfs(sx, sy); if(seen.at(gx).at(gy)) cout << "Yes" << endl; else cout << "No" << endl; }
Submission Info
Submission Time | |
---|---|
Task | A - 深さ優先探索 |
User | ryana |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1156 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:53:31: error: cannot convert ‘vvib {aka std::vector<std::vector<bool> >}’ to ‘void*’ for argument ‘1’ to ‘void* memset(void*, int, size_t)’ memset(seen, 0, sizeof(seen)); ^