Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define endl '\n'
- vector<bool> odwiedz;
- vector<vector<int> > G;
- void DFS(int v)
- {
- odwiedz[v] = true;
- for(int i = 0; i < G[v].size(); ++i)
- {
- int u = G[v][i];
- if(!odwiedz[u])
- DFS(u);
- }
- }
- bool czyistnieje(int v, int n)
- {
- return 0 <= x && x < n && 0 <= y && y < m;
- }
- VPII sasiedzi = {
- {-1, -1},
- {-1, 0},
- {-1, 1},
- {0, -1},
- {0, 1},
- {1, -1},
- {1, 0},
- {1, 1}
- };
- int main()
- {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- int n;
- cin >> n;
- vector<vector<int> > w(n, vector<int> (n));
- G.resize(n * n);
- odwiedz.resize(n * n);
- for(int i = 0; i < n; ++i)
- for(int j = 0; j < n; ++j)
- cin >> w[i][j];
- for(int x = 0; x < n; ++x)
- for(int y = 0; y < n; ++y)
- for(PII &p : sasiedzi)
- if(czyistnieje(x + p.ST, y + p.ND))
- G[nr(x, y)].emplace_back(nr(x + p.ST, y + p.ND));
- return 0;
- }
Add Comment
Please, Sign In to add comment