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

why wa?

Posted by niyuzhe at 2007-07-18 20:06:33 on Problem 1548
#include<iostream>
using namespace std;

int main()
{
	bool map[30][30];
	int r,c;
	while(1)
	{
		scanf("%d%d",&r,&c);
		if(r==-1&&c==-1)
			break;
		if(!r&&!c)
		{
			cout<<0<<endl;
			continue;
		}
		memset(map,0,sizeof(map));
		int g=0;
		map[r][c]=1;
		g++;
		while(1)
		{
			if(!r&&!c)
				break;
			scanf("%d%d",&r,&c);
			if(!r&&!c)
				break;
			map[r][c]=1;
			g++;
		}
		int ans=0;
		int right=0;
		while(g)
		{
			ans++;
			int rr=0;
			for(right=24;!map[rr][right]&&right>0;right--);
			for(int c=0;c<30;c++)
			{
				if(map[rr][c]==1)
				{
					g--;
					map[rr][c]=0;
				}
				while(c>=right)
				{
					if(rr==25)
						break;
					if(c==right)
					{
						g--;
						map[rr][c]=0;
					}
					rr++;
					for(right=29;!map[rr][right]&&right>0;right--);
				}
				if(map[rr][c]==1)
				{
					g--;
					map[rr][c]=0;
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

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