fork(1) download
  1. vector< string > arr;
  2. int dx[] = { 1 , -1 , 0, 0 };
  3. int dy[] = { 0 , 0, 1 , -1};
  4. int vis[1000][1000];
  5. int n , m;
  6. bool check( int x , int y )
  7. {
  8. if( x >= 0 && x < n && y >=0 && y < m && vis[x][y] == 0 && arr[x][y] == 'X' )
  9. return true;
  10. return false;
  11. }
  12.  
  13. void dfs( int x, int y )
  14. {
  15. vis[x][y] = 1;
  16. for( int i = 0 ; i < 4 ; i++)
  17. {
  18. int xx = x + dx[i];
  19. int yy = y + dy[i];
  20. if( check(xx,yy) )
  21. {
  22. dfs( xx,yy );
  23. }
  24. }
  25. }
  26.  
  27. int black(vector<string> &A) {
  28.  
  29. int cnt = 0;
  30. arr = A;
  31. n = A.size();
  32. m = A[0].length();
  33. memset( vis, 0, sizeof(vis) );
  34. for( int i = 0 ; i < A.size() ; i++ )
  35. {
  36. for( int j = 0 ; j < A[i].length() ; j++ )
  37. {
  38. if( check(i,j) )
  39. {
  40. dfs(i,j);
  41. ++cnt;
  42. }
  43. }
  44. }
  45.  
  46. return cnt;
  47. }
  48.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:1: error: 'vector' does not name a type
 vector< string > arr;
 ^
prog.cpp: In function 'bool check(int, int)':
prog.cpp:8:64: error: 'arr' was not declared in this scope
     if( x >= 0 && x < n && y >=0 && y < m && vis[x][y] == 0 && arr[x][y] == 'X' )
                                                                ^
prog.cpp: At global scope:
prog.cpp:27:11: error: 'vector' was not declared in this scope
 int black(vector<string> &A) {
           ^
prog.cpp:27:18: error: 'string' was not declared in this scope
 int black(vector<string> &A) {
                  ^
prog.cpp:27:27: error: 'A' was not declared in this scope
 int black(vector<string> &A) {
                           ^
prog.cpp:27:30: error: expected ',' or ';' before '{' token
 int black(vector<string> &A) {
                              ^
stdout
Standard output is empty