本文整理汇总了C++中vp::pb方法的典型用法代码示例。如果您正苦于以下问题:C++ vp::pb方法的具体用法?C++ vp::pb怎么用?C++ vp::pb使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vp
的用法示例。
在下文中一共展示了vp::pb方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: andrewScan
void andrewScan(vp &polys,P *ps,int n) {
u.clear(); l.clear();
polys.clear();
if(n < 3) return ;
sort(ps,ps+n,cmpx);
u.pb(ps[0]);
u.pb(ps[1]);
l.pb(ps[n-1]);
l.pb(ps[n-2]);
for(int i = 2;i < n;i++) {
for(int j = u.size();j >= 2 && ccw(u[j-2],u[j-1],ps[i]) != 2;j--)
u.pop_back();
u.pb(ps[i]);
}
for(int i = n-3;i >= 0;i--) {
for(int j = l.size();j >= 2 && ccw(l[j-2],l[j-1],ps[i]) != 2;j--)
l.pop_back();
l.pb(ps[i]);
}
polys = l;
for(int i = 1;i < u.size()-1;i++) polys.pb(u[i]);
}
示例2: dpri1
void dpri1()
{
int n = 10;
for(int i = 1;i<=n;++i)
{
int sign = (rand()%2)?1:-1;
int num = rand()%10;
int sign1 = (rand()%2)?1:-1;
int num1 = rand()%10;
test.pb(MP(sign*num,sign1*num1));
}
sort(test.begin(),test.end());
int u = unique(test.begin(),test.end())-test.begin();
for(int i = 0;i<u;++i)
{
pLL now = test[i];
while(test1.size() > 1 && det(test1[test1.size()-2],now,test1[test1.size()-1])<0)
test1.pop_back();
test1.pb(now);
}
ff(du,"list point(s):\n");
for(int i = 0;i<test.size();++i)
ff(du,"(%I64d,%I64d)",test[i].X,test[i].Y);
ff(du,"\nconvex hull point(s):\n");
for(int i = 0;i<test1.size();++i)
ff(du,"(%I64d,%I64d)",test1[i].X,test1[i].Y);
int _l = 0,_r = test1.size()-1;
pLL now = MP(-4,1);
while(_l<_r)
{
M;
if(mid == 0 || mid == test1.size()-1) break;
if((now*(test1[mid+1]-test1[mid])).X == 0 && (now*(test1[mid]-test1[mid-1])).X == 0) break;
if((now*(test1[mid+1]-test1[mid])).X > 0 && (now*(test1[mid]-test1[mid-1])).X < 0)
{_l = _r = mid;break;}
if((now*(test1[mid+1]-test1[mid])).X < 0) _l = mid+1;
else _r = mid-1;
}
ff(du,"\navailable point(s):\n");
for(int i = min(_l,_r);i<=max(_l,_r);++i)
ff(du,"(%I64d,%I64d)",test1[i].X,test1[i].Y);
}
示例3:
forn(i,sz(v)) {
while (sz(res)>1) {
P last1=res[sz(res)-2];
P last2=res[sz(res)-1];
if ((last2-last1)*(v[i]-last1)<eps)
res.pop_back();
else
break;
}
res.pb(v[i]);
}