Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
我的猥琐方法。。娃哈哈。。。/********************************************/ /*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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator