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:请问做出1468-Rectangles的人们,这题数据有什么陷阱?

Posted by coffeeandtea at 2007-07-15 18:04:52
In Reply To:请问做出1468-Rectangles的人们,这题数据有什么陷阱? Posted by:anonym11 at 2004-09-27 22:21:45
> 我把不被覆盖的长方形存起来,他们覆盖掉的长方形数也存起来,最后相加。
> 这是源程序:
> int main()
> {
> 	int x,mx,y,my,n,tang[5000],dd[5000];
> 	rectangle rec[5000];
> 	int i,j,t;
> 	while(cin>> n){
> 		t = 0;
> 		for(i = 0;i < n ;i ++)
> 			tang[i] = dd[i] = 0;
> 		for(i = 0;i < n;i ++)
> 		{
> 			cin >> x >> mx >> y >> my;
> 			for(j = 0;j < t;j ++)
> 			{
> 				if(x >= rec[j].x && mx <= rec[j].mx
> 				 && y >= rec[j].y && my <= rec[j].my)
> 				{
> 					tang[j] ++;
> 					if(x == rec[j].x && mx == rec[j].mx
> 				      && y == rec[j].y && my == rec[j].my && !dd[j])
> 					{
> 						tang[j] ++;
> 						dd[j] ++;
> 					}
> 					break;
> 				}
> 				else
> 					if(x <= rec[j].y && mx >= rec[j].mx
> 					&& y <= rec[j].y && my >= rec[j].my)
> 					{
> 						rec[j].x = x;rec[j].mx = mx;
> 						rec[j].y = y;rec[j].my = my;
> 						tang[j] ++;
> 						dd[j] == 0;
> 						break;
> 					}
> 			}
> 			
> 			if (j == t )
> 			{
> 				rec[t].x = x;rec[t].mx = mx;
> 				rec[t].y = y;rec[t].my = my;
> 				t ++;
> 			}
> 		}
> 		n = 0;
> 		for(i = 0;i < t;i ++)
> 		{
> 			n += tang[i];
> 			//cout << tang[i] << ' ' << rec[i].x << ' ' << rec[i].mx << ' ' << rec[i].my << endl;
> 		}
> 		cout << n << endl;
> 	}
> 	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