本文整理汇总了C++中VPII::back方法的典型用法代码示例。如果您正苦于以下问题:C++ VPII::back方法的具体用法?C++ VPII::back怎么用?C++ VPII::back使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VPII
的用法示例。
在下文中一共展示了VPII::back方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例3: trim
VPII trim(const VPII& v) {
VPII ret;
for (int i = 0; i < (int)v.size(); ++i) {
if (ret.size() > 1) {
if (ret.back().first == v[i].first && ret.back().first == (ret.end() - 2)->first) {
ret.pop_back();
} else if (ret.back().second == v[i].second && ret.back().second == (ret.end() - 2)->second) {
ret.pop_back();
}
}
if (ret.empty() || v[i] != ret.back()) {
ret.push_back(v[i]);
}
}
return ret;
}
示例4: path
VPII path(const PII& a, const PII& b, const VPII& w, int u) {
int i, t, k = 1, p = -1;
VPII ret;
// printf("[path] w.size() = %d\n", (int)w.size());
for (i = 1; i < (int)w.size(); ++i) {
t = intersection(a, b, w[i - 1], w[i]);
if (t != -1 && (p == -1 || p > t)) {
p = t;
k = i;
}
}
if (p != -1) {
ret.push_back(point(a, b, p - u));
if ((w[k - 1].first == w[k].first && w[k].first == ret.back().first) ||
(w[k - 1].second == w[k].second && w[k].second == ret.back().second)) {
++k;
}
// printf("k = %d\n", k);
for (i = k ; i < (int)w.size(); ++i) {
ret.push_back(ret.back());
if (i + 1 < (int)w.size() && sameside(w[i - 1], w[i], ret.back(), w[i + 1])) {
if (w[i - 1].first == w[i].first) {
ret.back().second = w[i].second - sign(w[i].second - w[i - 1].second) * u;
} else {
ret.back().first = w[i].first - sign(w[i].first - w[i - 1].first) * u;
}
} else {
if (w[i - 1].first == w[i].first) {
ret.back().second = w[i].second + sign(w[i].second - w[i - 1].second) * u;
} else {
ret.back().first = w[i].first + sign(w[i].first - w[i - 1].first) * u;
}
}
}
}
return ret;
}