Advertisement
Manioc

598D

Oct 22nd, 2018
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define MAX 1007
  3.  
  4. using namespace std;
  5.  
  6. int vis[MAX][MAX], value[MAX][MAX];
  7. pair<int, int> parent[MAX][MAX];
  8. char grid[MAX][MAX];
  9.  
  10. int _x[4] = {0,1,0,-1};
  11. int _y[4] = {1,0,-1,0};
  12. int n, m, k;
  13.  
  14. bool check(int x, int y){
  15.     return x > 0 && x <= n && y > 0 && y <= m;
  16. }
  17.  
  18. pair<int, int> actual;
  19. int dfs(int x, int y){
  20.     vis[x][y] = true;
  21.     parent[x][y] = actual;
  22.  
  23.     if(grid[x][y] == '*') continue;
  24.     for(int i = 0; i < 4; i++){
  25.         int l = x + _x[i];
  26.         int r = y + _y[i];
  27.         if(check(l, r)){
  28.             if(grid[l][r] == '*') value[no]++;
  29.             else value[no] += dfs(l, r);
  30.         }
  31.     }
  32.  
  33.     return value[no];
  34. }
  35. int main(){
  36.     scanf("%d %d %d", &n, &m, &k);
  37.  
  38.     for(int i = 0; i < n; i++){
  39.         for(int j = 0; j < m; j++){
  40.             scanf(" %c", &grid[i][j]);
  41.         }
  42.     }
  43.  
  44.     while(k--){
  45.         scanf("%d %d", &actual.first, &actual.second);
  46.         if(vis[actual.first][actual.second])
  47.     }
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement