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

崩溃

Posted by wangbaobao at 2009-05-02 20:28:43 on Problem 1974
崩溃,为什么re了!这题用排序吗?还是我这样模拟有问题
#include"iostream"
#define Max 5999
using namespace std;
int stone_list[Max][Max];
int main()
{
	int n;
	cin>>n;
	while(n--)
	{
		memset(stone_list,-1,sizeof(stone_list));
		int hang,lie,stone_num,num=0;
		cin>>hang>>lie>>stone_num;
		while(stone_num--)
		{
			int x,y;
			cin>>x>>y;
			stone_list[x][y]=1;
		}
		for(int i=1;i<=hang;i++)
			for(int j=1;j<=lie;j++)
			{
				if(stone_list[i][j]==1)
					   continue;
				else
				{
					stone_list[i][j]=1;
                    if(i-1>=1&&stone_list[i-1][j]!=1)
					{
						stone_list[i-1][j]=1;
						num++;
						
					}
					else if(i+1<=hang&&stone_list[i+1][j]!=1)
					{ 
						stone_list[i+1][j]=1;
						num++;
						
					}
					else if(j-1>0&&stone_list[i][j-1]!=1)
					{
						stone_list[i][j-1]=1;
						num++;
					}
					else if(j+1<=lie&&stone_list[i][j+1]!=1)
					{
						stone_list[i][j+1]=1;
						num++;
					}
				
				}
			}
			cout<<num<<endl;
	}
	return 1;
}





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