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 zhao999 at 2009-03-22 21:01:58 on Problem 1230
#include<iostream>
using namespace std;
int a[102][102];
int n,k,t,maxx,co;
struct p{
	int x;
	int y;
}p1,p2;
void input()
{
	int i;
	maxx=0;
	while(n--)
	{
		cin>>p1.x>>p1.y>>p2.x>>p2.y;
		int min=(p1.x<p2.x)?p1.x:p2.x;
		int max=(p1.x>p2.x)?p1.x:p2.x;
		if(maxx<max)
			maxx=max;
		for(i=min;i<=max;i++)
			a[p1.y][i]=max+1;
	}
}
void solve()
{
	int i,j,count=0;
	for(i=0;i<maxx;i++)
	{
		int c=0;
		for(j=0;j<co;j++)
			if(a[j][i]!=0)
				c++;
			if(c>k)
			{
				count++;
				//searchmaxwall();
				int e=i,len=0,wallmax=0,dewall,d;
				for(d=0;d<co;d++)
				{
					int m=a[d][i];
					while(a[d][e]!=0&&a[d][e]==m)
					{
						e++;
						len++;
					}
					if(len>wallmax)
					{
						wallmax=len;
						dewall=d;
					}
				}
				for(e=i;e<i+wallmax;e++)//dellwall
				{
					a[dewall][e]=0;
				}
			}
	}
	cout<<count<<endl;
}
int main()
{
	
	cin>>t;
	while(t--)
	{
		memset(a,0,sizeof(a));
		cin>>n>>k;
		co=n;
		input();
		solve();
	}
	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