POJ 2029 Get Many Persimmon Trees 简单搜索----解题报告

题目很简单...给你N个星星的坐标...找出在m*n的方框中最多能容纳几个星星...直接遍历一遍整个图...属于简单搜索~


#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
using namespace std;
int map[501][501];                                                         
int main()
{
//	freopen("in.txt","r",stdin);
	int x;
	while(cin>>x && x!=0)
	{
		memset(map,0,sizeof(map));
		int m,n,s,t,i,j;
		cin>>m>>n;
		while(x--)
		{
			int a,b;
			cin>>a>>b;
			map[b][a]=1;
		}
		/*for(i=1;i<=n;i++)
		{
			for(j=1;j<=m;j++)
			{
				cout<<map[i][j]<<" ";
			}
			cout<<endl;
		}*/
		cin>>s>>t;
		int max=0;
		for(i=1;i<=n-t+1;i++)
		{
			for(j=1;j<=m-s+1;j++)
			{
				int a1,b1,sum=0;
				for(a1=i;a1<=i+t-1;a1++)
				{
					for(b1=j;b1<=j+s-1;b1++)
					{
						sum+=map[a1][b1];
					}
				}
				max = sum>max?sum:max;
			}
		}
		cout<<max<<endl;
	}
    return 0;
}




posted @ 2012-08-09 02:34  Felix_F  阅读(130)  评论(0)    收藏  举报