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

OLE

Posted by 105082009046 at 2011-05-09 14:32:09 on Problem 2932
狂OLE
求高人指教
我用的是set
#include<stdio.h>
#include<iostream>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<string.h>
#define N 50000
#define ii __int64
using namespace std;
struct Line
{
	double x,y1,y2;
	int flag;
	int ind;
}ls[2*N];
bool hash[N];
map<double ,int> mp;
map<double ,int>::iterator beg,end;
set<ii> se;
set<ii>::iterator it;
int n;
double x[N],y[N],r[N];
int cmp(Line a,Line b)
{
	return a.x<b.x;
}
int main()
{
	int i;
	int j;
	int tn;
	while(scanf("%d",&n)!=EOF)
	{
		j=0;
		tn=n;
		mp.clear();
		for(i=0;i<n;i++)
		{
			scanf("%lf%lf%lf",&r[i],&x[i],&y[i]);
			ls[j].x=x[i]-r[i];
			ls[j].y1=y[i]-r[i];
			ls[j].y2=y[i]+r[i];
			ls[j].flag=1;
			ls[j].ind=i;
			j++;
			
			ls[j].x=x[i]+r[i];
			ls[j].y1=ls[j-1].y1;
			ls[j].y2=ls[j-1].y2;
			ls[j].flag=-1;
			ls[j].ind=i;

			mp[ls[j].y1]=1;
			mp[ls[j].y2]=1;
			j++;
		}
		n=j;
		sort(ls,ls+n,cmp);
		beg=mp.begin();
		end=mp.end();
		for(i=1;beg!=end;beg++,i++)
			beg->second=i;
		memset(hash,false,sizeof(hash));
		se.clear();
		ii num;
		for(i=0;i<n;i++)
		{
			ii ll=mp[ls[i].y1];
			ii rr=mp[ls[i].y2];
			num=ll*40000+rr;
			if(ls[i].flag==1)
			{	
				it=se.insert(num).first;
				if(it!=se.begin())
				{
					it--;
					if(*(it)%40000>rr && *(it)/40000<ll)
						hash[ls[i].ind]=true;
				}
			}
			else
			{
				se.erase(num);
			}
		}
		int cnt=0;
		for(i=0;i<tn;i++)
			if(!hash[i])
				cnt++;
		printf("%d\n",cnt);
		for(i=0;i<tn;i++)
			if(!hash[i])
			{
				printf("%d",i+1);
				break;
			}
		for(i++;i<tn;i++)
			if(!hash[i])
				printf(" %d",i+1);
		printf("\n");
	}
	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