本文整理汇总了C++中VPII::end方法的典型用法代码示例。如果您正苦于以下问题:C++ VPII::end方法的具体用法?C++ VPII::end怎么用?C++ VPII::end使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VPII
的用法示例。
在下文中一共展示了VPII::end方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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());
}
示例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: _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: _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;
}
示例7: 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;
}
示例8: 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);
}
示例9: main
int main() {
LL tot = 1;
LL n, m;
cin >> n;
for (int i=0; i<2*n; ++i) {
int a;
cin >> a;
x.push_back(MP(a, i%n));
}
sort(x.begin(), x.end());
cin >> m;
init(2*n+10, m);
for (int i=0,j=0,sz=(int)x.size(); i<sz; i=j) {
int p2 = 0;
for (j=i; j<sz&&x[j].first==x[i].first; ++j) p2 += (j + 1 < sz && x[j+1] == x[j]);
// cout << x[i].first << ' ' << j - i << ' ' << p2 << ' ' << r[j-i] << ' ' << cc[j-i] << endl;
tot = (tot * r[j-i] % m) * P(2, cc[j-i]-p2, m) % m;
}
cout << tot << endl;
return 0;
}
示例10: main
int main()
{
int tc;
scanf("%d",&tc);
while (tc--)
{
int m, n;
scanf("%d %d",&m, &n);
VPII segm;
for(int i=0;i<n;i++)
{
int st, en;
scanf("%d %d",&st, &en);
if(st<=en)
{
segm.push_back(make_pair(st,en));
segm.push_back(make_pair(st+m,en+m));
}
else
segm.push_back(make_pair(st,en+m));
}
printVector(segm);
if(n>m)
{
puts("NO");
continue;
}
sort(segm.begin(),segm.end());
cout << "After Sorting " << endl;
printVector(segm);
int T=0;
int i=0;
set < PII > que;
bool ok = true;
while(true)
{
if(que.empty())
{
if(i==segm.size())
break;
else
T = segm[i].first;
}
while(i<segm.size() && segm[i].first==T)
{
que.insert(make_pair(segm[i].second,i));
i++;
}
int ind = que.begin()->second;
que.erase(que.begin());
if(!(T>=segm[ind].first && T<=segm[ind].second))
{
ok = false;
break;
}
T++;
}
puts(ok?"YES":"NO");
}
}