#include#include using namespace std;const int SIZE = 100;int n, m, p, a[SIZE] [SIZE], count;void colour (int x, int y){\tCount ;\ta[x][y] = 1;\tif ((x > 1)&& (a[x-1][y] == 0))\t\tcolour( x - 1, y);\tif ((y> 1)&& (a[x][y-1] == 0))\t\tcolour( x, y- 1);\tif ((x < n)&& (a[x 1][y] == 0))\t\tcolour( x 1, y);\tif ((y < m)&& (a[x][y 1] == 0))\t\tcolour( x, y 1);}int main( ){\tint i, j, x, y, ans;\tmemset(a, 0, sizeof(a));\tcin >>n>>m>>p;\tfor(i =1 ; I <=p; i ) {\t\tcin>>x>>y;\t\ta[x][y] = 1;\t}\tans = 0;\tfor (i =1; i <=n; i )\t\tfor (j =1; j <=m;j )\t\t\tif (a[i][j] == 0)\t\t\t\t{count = 0;\t\t\t\tcolour (i , j);\t\t\t\tif (ans 输入:
6 5 9
1 4
2 3
2 4
3 2
4 1
4 3
4 5
5 4
6 4
输出:_________
发表评论 取消回复