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

老是Output Limit Exceeded。。。求助。。新手

Posted by lku941 at 2012-07-12 21:51:17 on Problem 1656
#include <stdio.h>
#include <string.h>

int main()
{
	int x, y, l, i, j;
	int n;
	char a[10];
	int b[101][101]={0};
	
	while (scanf("%d", &n)!=EOF)
	{
		for (i=0; i<n; i++)
		{
			scanf("%s", &a);

			if (strcmp(a, "WHITE")==0)
			{
				scanf("%d%d%d", &x, &y, &l);
					for (i=x-1; i<x+l-1; i++)
						for (j=y-1; j<y+l-1; j++)
							b[i][j]=0;
			}

			if (strcmp(a, "BLACK")==0)
			{
					scanf("%d%d%d", &x, &y, &l);
					for (i=x-1; i<x+l-1; i++)
						for (j=y-1; j<y+l-1; j++)
							b[i][j]=1;
			}
			
			if (strcmp(a, "TEST")==0)
			{
				int count=0;
					scanf("%d%d%d", &x, &y, &l);
					for (i=x-1; i<x+l-1; i++)
						for (j=y-1; j<y+l-1; j++)
							if (b[i][j]==1)
								count++;
				printf ("%d\n", count);
			}

		}
	}
	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