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

78道

Posted by zpdlut at 2010-09-12 18:23:04 on Problem 1656
#include<iostream>
#include<string>
#define MAX 100
using namespace std;
int set[MAX][MAX];
int main()
{
	int lines;
	cin>>lines;
	string s;
	int x,y,L;
	for(int i=0;i<lines;i++)
	{
		cin>>s>>x>>y>>L;
		int count=0;
		int Bx = x+L-1;
		int By = y+L-1;
		if(s.compare("BLACK")==0)
		{
			for(int i = x;i<=Bx;i++)
			{
				for(int j = y;j<=By;j++)
				{
					set[i][j] = 1;
				}
			}
		}
		else if(s.compare("WHITE")==0)
		{
			for(int i = x;i<=Bx;i++)
			{
				for(int j = y;j<=By;j++)
				{
					set[i][j] = 0;
				}
			}
		}
		else
		{
			for(int i = x;i<=x+L-1;i++)
			{
				for(int j = y;j<=y+L-1;j++)
				{
					if(set[i][j] == 1)
					{
						count++;
					}
				}
			}
			cout<<count<<endl;
		}
		count=0;
	}
	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