Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为什么总是 OLE呢?郁闷……

Posted by willard at 2007-09-20 11:05:23 on Problem 1562
void main()
{
	int m, n;
	int ways[16] = {0,1,1,1,1,0,1,-1,0,-1,-1,-1,-1,0,-1,1};
	scanf("%d %d", &m, &n);
	while(m>0 && m <101 && n>0 && n<101)
	{
		POINT map[101][101];
		int i, j, k, count=0;
		for(i=0; i < m; i++)
		{
			char temp[101];
			cin.getline(temp, 100);
			for(j = 0; j < n; j++)
			{
				map[i][j].ch = temp[j];
				map[i][j].value = 0;
				map[i][j].x = i;
				map[i][j].y = j;
			}
		}
		for(i=0; i < m; i++)
		{
			for(j = 0; j < n; j++)
			{
				if(map[i][j].value!=0 || map[i][j].ch=='*')
					continue;
				POINT * searlist[11000];
				int cur=0, p;
				searlist[cur++] = &map[i][j];
				for(p=0; p < cur; p++)
				{
					for(k = 0; k <= 14; k++)
					{
						int x = searlist[p]->x+ways[k],
							y = searlist[p]->y+ways[k+1];
						if(x>=m || x<0 || y>=n || y<0)
							continue;
						if(map[x][y].ch!='@' || map[x][y].value!=0)
							continue;
						map[x][y].value++;
						searlist[cur++] = &map[x][y];
					}
				}
				count++;
			}
		}
		printf("%d\n", count);
		scanf("%d %d", &m, &n);
	}
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator