提交时间:2024-01-21 15:15:59
运行 ID: 121101
#include<iostream> using namespace std; const int N = 20, way[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}}; bool a[N][N], b[N][N]; int ans = 0; void f(int x, int y){ if(x < 0 || y < 0 || x >= 20 || y >= 20 || a[x][y] || b[x][y]) return; b[x][y] = true; ans++; f(x, y+1); f(x+1, y); f(x, y-1); f(x-1, y); } int main(){ for(int i = 1; i <= 10; i++){ for(int j = 1; j <= 10; j++){ cin >> a[i][j]; if(a[i][j]) ans++; } } f(0, 0); cout << 400 - ans; return 0; }