• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ VPII类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中VPII的典型用法代码示例。如果您正苦于以下问题:C++ VPII类的具体用法?C++ VPII怎么用?C++ VPII使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了VPII类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:GENTLEMAN009,项目名称:Algorithm,代码行数:33,代码来源:LIS(stanford).cpp


示例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;
}
开发者ID:Crmiv,项目名称:AlgoSolution,代码行数:9,代码来源:1413gougou40.cpp


示例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;
}
开发者ID:KamikazeCJJ,项目名称:Heuristics-CodeForces-GYM,代码行数:9,代码来源:K.cpp


示例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;
}
开发者ID:Crmiv,项目名称:AlgoSolution,代码行数:9,代码来源:1413gougou40.cpp


示例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;
}
开发者ID:Crmiv,项目名称:AlgoSolution,代码行数:9,代码来源:1413gougou40.cpp


示例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);
        }
}
开发者ID:KamikazeCJJ,项目名称:Heuristics-CodeForces-GYM,代码行数:51,代码来源:je.cpp


示例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;
}
开发者ID:pranjal-rai,项目名称:codeforces,代码行数:46,代码来源:p2.cpp


示例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;

		}
}
开发者ID:varenya,项目名称:algorithms,代码行数:10,代码来源:littlejhool.cpp


示例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);
	}
开发者ID:gm561,项目名称:algo_lab_to_exam,代码行数:11,代码来源:entries.cpp


示例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;
}
开发者ID:bristy,项目名称:HackYourself,代码行数:39,代码来源:arches_new.cpp


示例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());
}
开发者ID:Crmiv,项目名称:AlgoSolution,代码行数:13,代码来源:1413gougou40.cpp


示例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;
}
开发者ID:anveshi,项目名称:Competitive-Programming,代码行数:41,代码来源:545-C-11161476.cpp


示例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;
}
开发者ID:pranjal-rai,项目名称:kd-tree,代码行数:24,代码来源:kdtree_static.cpp


示例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;
}
开发者ID:KamikazeCJJ,项目名称:Heuristics-CodeForces-GYM,代码行数:12,代码来源:je.cpp


示例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);
}
开发者ID:Crmiv,项目名称:AlgoSolution,代码行数:23,代码来源:2696.cpp


示例16: 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");
	}
}
开发者ID:varenya,项目名称:algorithms,代码行数:69,代码来源:littlejhool.cpp


示例17: 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;
}
开发者ID:Crmiv,项目名称:AlgoSolution,代码行数:37,代码来源:2696.cpp


示例18: 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;
}
开发者ID:Crmiv,项目名称:AlgoSolution,代码行数:16,代码来源:2696.cpp


示例19: main

int main()
{
    freopen("Text/QCJ1.txt","r",stdin);

    int i = 0, h, w = 0, prevv=-2, tot=0, steps=0, len;
	VPII walk;
	while(gets(board[i])) i++;
	h = i-1;
	len = strlen(board[i-1]);
	while(w<len)
	{
		if(board[h][w]=='/')
		{
			if(prevv!=1)
			{
				walk.push_back(pair<char,int>(prevv,steps));
				steps = 0;
			}
			steps++;
			prevv = 1;
			w++;
			tot++;
		}
		else if(board[h][w]=='_')
		{
			if(prevv!=0)
			{
				walk.push_back(pair<char,int>(prevv,steps));
				steps = 0;
			}
			steps++;
			prevv = 0;
			w++;
			tot++;
		}
		else if(board[h][w]=='\\')
		{
			if(prevv!=-1)
			{
				walk.push_back(pair<char,int>(prevv,steps));
				steps = 0;
			}
			steps++;
			prevv = -1;
			w++;
			tot++;
		}
		else
		{
			if(prevv==-1)
			{
				if(h == i) break;
				else h++;
			}
			else if(prevv==0)
			{
				h++;
			}
			else if(prevv==1)
			{
				h--;
			}
		}
	}
	walk.push_back(pair<char,int>(prevv,steps));
	printf("Total Walk Distance = %d\n", tot);
	for(i=0; i<walk.size(); i++)
	{
		if(walk[i].first==-1) printf("Down %d steps\n", walk[i].second);
		else if(walk[i].first==0) printf("Walk %d steps\n", walk[i].second);
		else if(walk[i].first==1) printf("Up %d steps\n", walk[i].second);
	}

    return 0;
}
开发者ID:vijaynitrr,项目名称:Spoj,代码行数:75,代码来源:QCJ1.cpp


示例20: main

int main() {
	freopen("cut.in", "rt", stdin);
	freopen("cut.out", "wt", stdout);
	cin >> n >> m;
	ZERO(cc), ZERO(ff);
	REPN(i, n) {
		int a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		cc[a][b] += c;
		cc[b][a] += c;
		e.PB(MP(a, b));
	}
开发者ID:hrnn,项目名称:olymp,代码行数:13,代码来源:16_56_56_12_B_6889.CPP



注:本文中的VPII类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ VPackBuilder类代码示例发布时间:2022-05-31
下一篇:
C++ VP56Context类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap