2 solutions
-
0
#include using namespace std; int n, ans = 0; char a[1005][1005]; int water(int x, int y){ if(x < 1 || y < 1 || x > n || y > n || a[x][y] == '*' || a[x][y] == ' ') return 0; a[x][y] = ' '; ans++; water(x + 1, y); water(x, y + 1); water(x - 1, y); water(x, y - 1); return ans; } int main(){ cin >> n; for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++){ cin >> a[i][j]; } } cout << water(1, 1); return 0; }
Information
- ID
- 50
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 6
- Tags
- # Submissions
- 59
- Accepted
- 18
- Uploaded By