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

我的猥琐方法。。娃哈哈。。。

Posted by likit at 2010-02-08 10:11:56 on Problem 1151
/********************************************/
/*Discrete with map(two demension)*/
#define MAXP 6000
#define K 1000
double lenx[MAXP],leny[MAXP];
int cnt,nx,ny;
set<double> posx,posy;
map<int,int> hashx,hashy;

void Discrete()
{
	memset(lenx,0,sizeof(lenx));hashx.clear();cnt = 0;
	memset(leny,0,sizeof(leny));hashy.clear();
	double temp;
	set<double>::iterator it = posx.begin();
	while(it != posx.end())
	{
		hashx[(int)(K * (*it))] = cnt;
		if(cnt != 0)	lenx[cnt - 1] = *it - temp;
		temp = *it;
		it++;cnt++;
	}
	nx = cnt;
	cnt = 0;
	it = posy.begin();
	while(it != posy.end())
	{
		hashy[(int)(K * (*it))] = cnt;
		if(cnt != 0)	leny[cnt - 1] = *it - temp;
		temp = *it;
		it++;cnt++;
	}
	ny = cnt;
}
/********************************************/

用map离散前乘个大一点的数,害怕rp不够的话可以把K换成某个质数,就这样AC拉~~!

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