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

一次ac

Posted by zpdlut at 2010-09-24 14:40:34 on Problem 1693
#include<iostream>
using namespace std;
struct horizon
{
	int hx1;
	int hy1;
	int hx2;
	int hy2;
};
struct vertion
{
	int vx1;
	int vy1;
	int vx2;
	int vy2;
};
int comv(const void * A,const void * B)
{
	vertion v = *(vertion *)A;
	vertion v1 = *(vertion *)B;
	return v.vx1-v1.vx1;
}
int comh(const void * A,const void * B)
{
	horizon h = *(horizon *)A;
	horizon h1 = *(horizon *)B;
	return h.hy1-h1.hy1;
}
int main()
{
	horizon h[101];
	vertion v[101];
	int case_num,h_num,v_num;
	cin>>case_num;
	for(int i=0;i<case_num;i++)
	{
		h_num=0;
		v_num=0;
		int test_num;
		int x1,y1,x2,y2;
		cin>>test_num;
		for(int j=0;j<test_num;j++)
		{
			cin>>x1>>y1>>x2>>y2;
			if(x1 == x2)
			{
				v[v_num].vx1=x1;
				v[v_num].vy1=y1<y2?y1:y2;
				v[v_num].vx2=x2;
				v[v_num].vy2=y2>y1?y2:y1;
				v_num++;
			}
			else
			{
				h[h_num].hx1=x1<x2?x1:x2;
				h[h_num].hy1=y1;
				h[h_num].hx2=x2>x1?x2:x1;
				h[h_num].hy2=y2;
				h_num++;
			}
		}
		qsort(v,v_num,sizeof(v[0]),comv);
		qsort(h,h_num,sizeof(h[0]),comh);
		int result = 0;
		for(int i=0;i<=v_num-2;i++){
			for(int j=i+1;j<=v_num-1;j++){
				for(int k=0;k<=h_num-2;k++){
					for(int z=k+1;z<=h_num-1;z++){
						if(v[i].vy1<=h[k].hy1&&v[i].vy2>=h[z].hy1&&v[j].vy1<=h[k].hy1&&v[j].vy2>=h[z].hy1&&
							h[k].hx1<=v[i].vx1&&h[k].hx2>=v[j].vx1&&h[z].hx1<=v[i].vx1&&h[z].hx2>=v[j].vx1)
							result++;

					}	
				}
			}
		}
		cout<<result<<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