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

Re:二维树状树组

Posted by yinxmm at 2012-05-24 14:06:56 on Problem 1656
In Reply To:二维树状树组 Posted by:duhongguang at 2012-05-06 17:54:04
#include<cstdio>
#include<iostream>
#include<cstring>


using namespace std;
int n,x,y,l;
int ans,ask;
char as[1100];
bool map[110][110];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		cin>>as;
		scanf("%d%d%d",&x,&y,&l);
		for(int i=x;i<=x+l-1;i++)
		for(int j=y;j<=y+l-1;j++)
		{
			if(as[0]=='B')
				map[i][j]=true;
			if(as[0]=='W')
				map[i][j]=false;
			if(as[0]=='T')
				{
					ask=1;
					if(map[i][j]==true)
					ans++;
				}
		}
		if(ask==1)
		printf("%d\n",ans);
		ans=ask=0;
	}
	system("pause");
	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