Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define MAX 1007
- using namespace std;
- int vis[MAX][MAX], value[MAX][MAX];
- pair<int, int> parent[MAX][MAX];
- char grid[MAX][MAX];
- int _x[4] = {0,1,0,-1};
- int _y[4] = {1,0,-1,0};
- int n, m, k;
- bool check(int x, int y){
- return x > 0 && x <= n && y > 0 && y <= m;
- }
- pair<int, int> actual;
- int dfs(int x, int y){
- vis[x][y] = true;
- parent[x][y] = actual;
- if(grid[x][y] == '*') continue;
- for(int i = 0; i < 4; i++){
- int l = x + _x[i];
- int r = y + _y[i];
- if(check(l, r)){
- if(grid[l][r] == '*') value[no]++;
- else value[no] += dfs(l, r);
- }
- }
- return value[no];
- }
- int main(){
- scanf("%d %d %d", &n, &m, &k);
- for(int i = 0; i < n; i++){
- for(int j = 0; j < m; j++){
- scanf(" %c", &grid[i][j]);
- }
- }
- while(k--){
- scanf("%d %d", &actual.first, &actual.second);
- if(vis[actual.first][actual.second])
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement