Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Point {
- int x = 0;
- int y = 0;
- };
- const Point operator+(const Point& lhs, const Point& rhs) {
- return {lhs.x + rhs.x, lhs.y + rhs.y}; // C++14
- // return Point{lhs.x + rhs.x, lhs.y + rhs.y}; // C++11
- }
- void bfs(const Matrix<int> a, int N, int M) {
- const auto inside = [N, M] (const Point& p) {
- return p.x >= 0 && p.y >= 0 && p.x < N && p.y < M;
- };
- // ...
- while (!q.empty()) {
- const Point c = q.top();
- // ...
- for (auto dir : dirs) {
- const Point next_c = c + dir;
- if (inside(next_c) && !visited(next_c)) {
- q.push(next_c);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement