本文整理汇总了C++中VPII类的典型用法代码示例。如果您正苦于以下问题:C++ VPII类的具体用法?C++ VPII怎么用?C++ VPII使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VPII类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LongestIncreasingSubsequence
VI LongestIncreasingSubsequence(VI v)
{
VPII best;
VI dad(v.size(), -1);
for (int i = 0; i < v.size(); i++)
{
#ifdef STRICTLY_INCREASNG
PII item = make_pair(v[i], 0);
VPII::iterator it = lower_bound(best.begin(), best.end(), item);
item.second = i;
#else
PII item = make_pair(v[i], i);
VPII::iterator it = upper_bound(best.begin(), best.end(), item);
#endif
if (it == best.end())
{
dad[i] = (best.size() == 0 ? -1 : best.back().second);
best.push_back(item);
}
else
{
dad[i] = dad[it->second];
*it = item;
}
}
VI ret;
for (int i = best.back().second; i >= 0; i = dad[i])
ret.push_back(v[i]);
reverse(ret.begin(), ret.end());
return ret;
}
示例2: _minpres3
VPII _minpres3(VPII v) {
VPII ret(v);
for (VPII::iterator i = v.begin(); i != v.end(); ++i) {
swap(i->first, i->second);
}
uniform(v);
ret = min(ret, v);
return ret;
}
示例3: boundary
VPII boundary(PII a)
{
VPII ret;
ret.PB({a.F,0});
ret.PB({a.F,L});
ret.PB({0,a.S});
ret.PB({W,a.S});
return ret;
}
示例4: _minpres1
VPII _minpres1(VPII v) {
VPII ret(_minpres2(v));
for (VPII::iterator i = v.begin(); i != v.end(); ++i) {
i->first = -i->first;
}
uniform(v);
ret = min(ret, _minpres2(v));
return ret;
}
示例5: _minpres2
VPII _minpres2(VPII v) {
VPII ret(_minpres3(v));
for (VPII::iterator i = v.begin(); i != v.end(); ++i) {
i->second = -i->second;
}
uniform(v);
ret = min(ret, _minpres3(v));
return ret;
}
示例6: back
void back(int mask){
if(printed)return;
VPII cpy=ar;
int topleft, p=ar.size(), maxh=0, dist=0;
for(int i=0; i<p; i++){
if(ar[i].S>maxh)
maxh=ar[i].S, topleft=i;
}
for(int i=0; i<topleft; i++)
dist += ar[i].F;
if(maxh==0){
if(mask==(1<<N)-1)
print();
return ;
}
for(int i=0; i<N; i++)
if(not (mask&(1<<i))){
if(ar[topleft].F>=rect[i].F and ar[topleft].S>=rect[i].S){
ans.pb(node(dist, ar[topleft].S-rect[i].S, dist + rect[i].F, ar[topleft].S));
int oldwidth = ar[topleft].F;
ar[topleft].F = rect[i].F;
ar[topleft].S -= rect[i].S;
if(oldwidth!=rect[i].F)
ar.insert(ar.begin() + topleft + 1, {oldwidth-rect[i].F, maxh});
merge(ar);
back(mask|(1<<i));
ans.pop_back();
ar = cpy;
}
swap(rect[i].F, rect[i].S);
if(ar[topleft].F>=rect[i].F and ar[topleft].S>=rect[i].S){
ans.pb(node(dist, ar[topleft].S-rect[i].S, dist + rect[i].F, ar[topleft].S));
int oldwidth = ar[topleft].F;
ar[topleft].F = rect[i].F;
ar[topleft].S -= rect[i].S;
if(oldwidth!=rect[i].F)
ar.insert(ar.begin() + topleft + 1, {oldwidth-rect[i].F, maxh});
merge(ar);
back(mask|(1<<i));
ans.pop_back();
ar = cpy;
}
swap(rect[i].F, rect[i].S);
}
}
示例7: main
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(NULL);
int n,var,i,l,flag,d,j;
vector <VI> v(100010);
VPII vec;
cin >>n;
for(i=0;i<n;i++)
{
cin >>var;
v[var].PB(i);
}
for(i=1;i<=100000;i++)
{
l=v[i].size();
if(l==0)
continue;
if(l==1)
{
vec.PB(MP(i,0));
continue;
}
if(l==2)
{
vec.PB(MP(i,v[i][1]-v[i][0]));
continue;
}
flag=1;
d=v[i][1]-v[i][0];
for(j=2;j<l;j++)
{
if(v[i][j]-v[i][j-1]!=d)
flag=0;
}
if(flag==0)
continue;
else
vec.PB(MP(i,d));
}
l=vec.size();
cout <<l<<"\n";
for(i=0;i<l;i++)
cout <<vec[i].F<<" "<<vec[i].S<<"\n";
return 0;
}
示例8: printVector
void printVector(VPII segm){
cout << " print vector : " << endl;
for(int i=0;i<segm.size();i++){
cout << segm[i].first << " " << segm[i].second << " " << endl;
}
}
示例9: BriArt
void BriArt(VPII &res) {
res.clear(); br = &res;
t = 0;
REP(x, SIZE(g)) g[x].art = g[x].d = 0;
REP(x, SIZE(g)) if(!g[x].d) {
g[x].d=++t;
int c = 0;
FOREACH(it, g[x]) if (!g[it->v].d) {c++; BriArtR(it->v, x);}
g[x].art = (c>1);
}
示例10: check
bool check(string word){
int A = 0;
int B = 0;
int n = word.length();
VPII arches ;
int lastA = -1;
int lastB = -1;
REP(i, n){
if(word[i] == 'A'){
A++;
if(lastA == -1){
lastA = i;
} else {
arches.pb(mp(lastA, i));
lastA = -1;
}
} else {
B++;
if(lastB == -1){
lastB = i;
} else {
arches.pb(mp(lastB, i));
lastB = -1;
}
}
}
if(A%2 || B%2){
return false;
}
for(int i = 1; i< arches.size(); i++){
if(overlap(arches[i-1], arches[i])){
return false;
}
}
return true;
}
示例11: uniform
void uniform(VPII& v) {
int x = v.front().first;
int y = v.front().second;
for (VPII::const_iterator i = v.begin(); i != v.end(); ++i) {
x = min(x, i->first);
y = min(y, i->second);
}
for (VPII::iterator i = v.begin(); i != v.end(); ++i) {
i->first -= x;
i->second -= y;
}
sort(v.begin(), v.end());
}
示例12: main
int main(){
VPII v;
v.clear();
LL n,i,j,x,y;
cin >> n;
pair <LL,LL> p[100005];
for(i=0;i<n;i++){
cin >> p[i].ff >> p[i].ss;
}
sort(p,p+n);
// for(i=0;i<n;i++)
// trace2(p[i].ff,p[i].ss);
for(i=0;i<n;i++){
x = p[i].ff;y=p[i].ss;
if(i==n-1)
v.pb(mp(x+y,x));
else{
if(p[i+1].ff>x+y)
v.pb(mp(x+y,x));
}
if(i==0)
v.pb(mp(x,x-y));
else{
if(p[i-1].ff<x-y)
v.pb(mp(x,x-y));
}
}
sort(v.begin(),v.end());
LL ans=0,lf=-MOD;
int sz = v.size();
for(i=0;i<sz;i++){
//trace2(v[i].first,v[i].second);
//trace2(lf,v[i].second);
if(v[i].second>lf){ans++;
lf = v[i].first;
// trace2(v[i].second,v[i].first);
}
}
cout << ans << endl;
return 0;
}
示例13: main
int main()
{
srand(time(NULL));
FastIO();
// Keeps track of all elements in kd-tree
VPII vec;
kdtree *rootaddr = NULL;
int n, p_x, p_y;
n = 100;
for(int i = 0 ; i < n ; i++) {
p_x = rand() % 1000;
p_y = rand() % 1000;
vec.push_back(make_pair(p_x, p_y));
}
rootaddr = static_build(rootaddr, vec, 0, 0, n - 1);
// Uncomment the below part to print the kd-tree (preorder traversal)
/*
cout << "tree traversal\n";
print(rootaddr, 0, 'a');
*/
return 0;
}
示例14: merge
void merge(VPII& ar){
VPII ret;
ret.pb(ar[0]);
for(int i=1; i<ar.size(); i++){
assert(ar[i].F);
if(ar[i].S==ret.back().S)
ret.back().F+=ar[i].F;
else
ret.pb(ar[i]);
}
ar=ret;
}
示例15: gao
VPII gao(const VPII& v, const VPII& w, int u) {
int i, j;
VPII p, q, r;
for (i = 1; i < (int)v.size() && p.empty(); ++i) {
// printf("i = %d\n", i);
p = path(v[i - 1], v[i], w, u);
}
if (p.empty()) {
return v;
}
for (j = (int)v.size() - 2; j >= 0 && q.empty(); --j) {
// printf("j = %d\n", j);
q = path(v[j + 1], v[j], w, u);
}
--i;
++j;
// printf("i = %d; j = %d\n", i, j);
r.insert(r.end(), v.begin(), v.begin() + i);
r.insert(r.end(), p.begin(), p.end());
r.insert(r.end(), q.rbegin(), q.rend());
r.insert(r.end(), v.begin() + j + 1, v.end());
return trim(r);
}