FZU - 2064 找位置

#include <cstdio>

int main() {
	int t;
	scanf("%d", &t);
	while (t--) {
		int arr[105][105] = {0}, n, m, w;
		scanf("%d%d%d", &n, &m, &w);
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++)
				scanf("%d", &arr[i][j]);

		int sum = 0, k;
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++)
				if (arr[i][j] == 0) {
					for (k = j + 1; arr[i][k] == 0 && k < m; k++);
					if (k - j >= w)
						sum += k - j - w + 1;
					j = k;
				}

		printf("%d\n", sum);
	}
	return 0;
}

你可能感兴趣的:(FZU - 2064 找位置)