Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <cstring>
- #include <algorithm>
- #include <vector>
- using namespace std;
- int n, m, a, b, cnt, arr[101][101], lamps[101], sum;
- void dfs(int v)
- {
- cnt++;
- lamps[v] = 1;
- for (int i = 0; i < n; i++)
- {
- if(arr[v][i] && !lamps[i]) dfs(i);
- }
- }
- int main()
- {
- //--------------------------------
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- cout.tie(0);
- //--------------------------------
- cin >> n >> m;
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < n; j++)
- {
- cin >> arr[i][j];
- }
- }
- dfs(m-1);
- cout << cnt;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement