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

C++ vii类代码示例

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

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



在下文中一共展示了vii类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: goto_free_point

int goto_free_point(const vii& g, int& t){
  vi bfs;
  vi res;
  vi revisited;
  revisited.resize(num_intersect);

  for(int i=0; i < num_intersect; ++i)
    revisited[i] = 0;

  for(int i=0; i < (int)g.size(); ++i)
    bfs.push_back(g[i].first);
  int go;
  while(!bfs.empty()){
    go = bfs.back();
    bfs.pop_back();
    if(visited[go] && !revisited[go]){
      res.push_back(go);
      revisited[go] = 1;
      for(int i=0; i < (int)g.size(); ++i)
        if(!revisited[go])
          bfs.push_back(graph[go][i].first);
    }
    else{
      break;
    }
  }
        for(int i=0; i < (int)res.size(); ++i)
        vpath[veh].push_back(res[i]);
      return go;
}
开发者ID:remyzorg,项目名称:gphc2014,代码行数:30,代码来源:routing.cpp


示例2: out

void out(const vii & x, int b, int e) {
    if (b >= e || x[b].first == x[e - 1].first)
        return;
    int mid = x[(b + e) / 2].first;
    int i = b;
    for (; i < x.size() && x[i].first < mid; ++i)
        res.push_back(pii(mid, x[i].second));
    out(x, b, i);
    for (i = e - 1; i >= b && x[i].first > mid; --i)
        res.push_back(pii(mid, x[i].second));
    out(x, i + 1, e);
}
开发者ID:DmitryPro,项目名称:code_antiplagiat,代码行数:12,代码来源:7502.cpp


示例3: main

	int main(){
		FASTER;
		vii temp;
		cin >> n;
		s1=s2=0;
		for (int i = 0,t; i < n; ++i) {
			cin >> t;
			temp.push_back(ii(t,i));
		}
		sort(temp.begin(),temp.end());
		for (int i = 0; i <n; ++i) {
			a.push_back(temp[i].first);
			ida.push_back(temp[i].second+1);
		}
		temp.clear();
		cin >> m;
		for (int i = 0,t; i <m; ++i) {
			cin >> t;
			temp.push_back(ii(t,i));
		}
		sort(temp.begin(),temp.end());
		for (int i = 0; i < m; ++i) {
			b.push_back(temp[i].first);
			idb.push_back(temp[i].second+1);
		}
		temp.clear();

		s1=s2=0;
		for (int i = 0; i < a.size(); ++i) {
			s1+=a[i];
		}
		for (int i = 0; i < b.size(); ++i) {
			s2+=b[i];
		}



		sol();sol();
	//	printf("%lld %lld\n",s1,s2);


		cout << abs(s1-s2) << endl;

		cout  << ans.size() << endl;
		if(ans.size()){
			for (int i = 0; i < ans.size(); ++i) {
				cout << ans[i].first << " " << ans[i].second  << endl;
			}
		}

		return 0;
	}
开发者ID:giusevtr,项目名称:problemsolving,代码行数:52,代码来源:D.cpp


示例4: primeFactors

void primeFactors(ll N, vii &factors) {
	ll PF_idx = 0, PF = primes[PF_idx];
	while (PF * PF <= N){
		ii f(PF, 0);
		while (N % PF == 0){
			N /= PF;
			f.second++;
		}
		if (f.second > 0){
			factors.push_back(f);
		}
		PF = primes[++PF_idx];
	}
	if (N != 1) factors.push_back(ii(N,1));
}
开发者ID:nmackay132,项目名称:CompetitveProgramming,代码行数:15,代码来源:Factovisers.cpp


示例5: get_road

int get_road(int ridx, const vii& g, int &t){
  coord_t dir = directions[ridx];
  double min_dist = 800000000.0;
  int res = -1;
  for(int i = 0; i < (int)g.size(); ++i){
    double min_dist2= dist(dir, coords[g[i].first]);
    if(visited[g[i].first] < 2 && min_dist > min_dist2){
      min_dist = min_dist2;
      res = i;
    }
  }
  // if(res == -1) return goto_free_point(g, t);
  // return res;
  return (res == -1)?droad(rd)%g.size():res;
}
开发者ID:remyzorg,项目名称:gphc2014,代码行数:15,代码来源:routing.cpp


示例6: main

int main(){
    int n, i, k, a,b, maxlis;
    scanf("%d", &n);
    for(i=0; i<n; i++) {
        scanf("%d %d", &a, &b);
        pairs.push_back(make_pair(a,b));
    }

    vii::iterator low;
    lis.push_back(pairs[0]);

    for(i=1, k=1, maxlis=1; i<n; i++){
        if(pairs[i].first>lis[k].first && pairs[i].second>lis[k].second) {
            if(k+1==lis.size())
                lis.push_back(pairs[i]);
            else
                lis[++k]=pairs[i];
            if(k+1>maxlis) maxlis=k+1;
        } else{
            low = lower_bound(lis.begin(), lis.begin()+k+1, pairs[i]);
            lis[k=low-lis.begin()]=pairs[i];
        }
    }
    printf("%d\n", maxlis);
    return 0;
}
开发者ID:ABHINAVKR,项目名称:ACM,代码行数:26,代码来源:LIS2.cpp


示例7: ok

bool ok(int l){

	int c1 = 0;
	int c2 = 0;

	for (int i = 1; i <= l; ++i) {
		if(a[i] < a[c1])c1 = i;
		if(b[i] < b[c2])c2 = i;
	}
	vector<pair<ll, ii> > p;
	for (int i = 0; i < m; ++i) {
		if(tp[i]==1) p.push_back(pair<ll, ii> (a[c1]*c[i], ii(i,c1)));
		if(tp[i]==2) p.push_back(pair<ll, ii> (b[c2]*c[i], ii(i,c2)));
	}
	sort(p.begin(), p.end());
	int sum = 0;
	int cnt = 0;
	X.clear();
	for (int i = 0; i < p.size(); ++i) {
		if(sum+p[i].first>s)break;
		sum+=p[i].first;
		X.push_back(p[i].second);
		cnt++;
	}
	return cnt >= k;
}
开发者ID:giusevtr,项目名称:problemsolving,代码行数:26,代码来源:D.cpp


示例8: main

int main() {
    ios::sync_with_stdio(0);
    double d;
    int m, tc = 1;
    while( cin >> d >> m) {
        cout << "Case " << tc++ << ":" << endl;
        memo.clear(); memo.resize(105, -1);
        prices.clear(); prices.resize(m + 1);
        prices[0].first = 1; prices[0].second = (d + eps) * 100;
        for(int i = 1; i <= m; i++) {
            int tmp; cin >> tmp >> d;
            prices[i].first = tmp; prices[i].second = (d + eps) * 100;
        }
        string str;
        cin.get();
        getline(cin, str);
        stringstream ss(str);
        int tmp;
        while(ss >> tmp) {
            cout << "Buy " << tmp << " for $" << fixed << setprecision(2) << (double)solve(tmp) / 100 << endl;
        }
    }

    return 0;
}
开发者ID:mehranagh20,项目名称:uvaSolvedPromblems,代码行数:25,代码来源:10980-Lowest-Price-in-Town.cpp


示例9: main

int main(){
    int vertices,arestas,caso=1;
    while(scanf("%d %d", &vertices, &arestas) && vertices && arestas){
        for(int i = 0; i < arestas; i++)
        {
            int u,v;
            scanf("%d %d", &u, &v);
            adj[u].push_back(v);
            adj[v].push_back(u);
        }
        memset(dfs_num, -1 , sizeof(dfs_num));
        memset(visitados, 0 , sizeof(visitados));
        dfsNumbercounter = 0;

        for(int i = 0; i <= vertices; i++){
            if(dfs_num[i]==DFS_WHITE){findBridges(i);}
        }

        cout << caso++ << endl;
        cout << endl;

        for(int i = 0; i < bridge.size();i++){
            printf("%d %d\n",bridge[i].first,bridge[i].second);
        }
        cout << "#" << endl;
        bridge.clear();
        int i=vertices+5;
        while(i--){
            adj[i].clear();
        }
    }
    return 0;
}
开发者ID:lcavalcante,项目名称:AA,代码行数:33,代码来源:main.cpp


示例10: main

int main(){
	FASTER;
	int n;
	int Case=1;
	while(cin >> n, n){
		cas.clear();
		for(int i = 0 ; i < n ; i++){
			int a,m,g;
			cin >> a >> m >> g;
			castle c{a,m,g};
			C.push_back(c);
			cas.push_back(ii(max(a,m+g), m+g));
		}
		adj.assign(n,vi());
		for(int i = 0 ; i < n-1;i++){
			int u,v;cin >> u >> v;
			u--,v--;
			adj[u].push_back(v);
			adj[v].push_back(u);
		}	
		ii ans = ii(1e9,1e9);
		
		for(int i = 0 ; i < 1;i++){
			ans = min(ans,dfs(i));
		}
		cout << "Case " << (Case++)<< ": ";
		cout << ans.first << endl;
	}
}
开发者ID:giusevtr,项目名称:problemsolving,代码行数:29,代码来源:1093-Castles.cpp


示例11: main

int main()
{
	ifstream fin("marathon.in");
	ofstream fout("marathon.out");

	int N; 
	fin >> N;
	points.resize(N);
	for (int i = 0; i < N; ++i)
	{
		fin >> points[i].first >> points[i].second;
	}

	T.resize(N - 2);
	res.resize(N - 2);

	T[0].first = 0;
	T[0].second =  dist_cont(2, N-1);
	res[0] = T[0].first + T[0].second + dist_two(0, 2);
	int result = res[0];

	for (int k = 1; k <= N - 3; ++k)
	{
		T[k].first = T[k - 1].first + dist_two(k - 1, k);
		T[k].second = T[k - 1].second - dist_two(k + 1, k+2);
		res[k] = T[k].first + T[k].second + dist_two(k, k + 2);
		result = min(result, res[k]);
	}
	fout << result << '\n';
	
	return 0;
}
开发者ID:YourRatzon,项目名称:Algorithmic_Problems,代码行数:32,代码来源:marathon.c


示例12: doGreedy

void doGreedy()
 {
 	int cek;
 	LL total = 0;
 	// SOrt dlu
 	sort(dragons.begin(), dragons.end());
 	sort(knights.begin(), knights.end());
 	
 	REP(a,n)
 	{
 		cek = 0;
 		REP(b,m)
 		{
 			//printf("dragon : %d \n",dragons[a]);
 			
 			// Ga bisa dipake lagi
 			if(knights[b].second == 1) continue;
 			
 			if(knights[b].first >= dragons[a] )
 			{
 				//printf("KILL by : %d\n",knights[b].first);
 				cek = 1;
 				total += knights[b].first;
 				knights[b].second = 1;
 				break;
 			}
 		}
 		if(!cek)
 		{
 			break;
 		}
 	}
开发者ID:Delpro-Club,项目名称:Programming-Code,代码行数:32,代码来源:DragonOfWaterloo.cpp


示例13: main

int main() {
    freopen("milk.in", "r", stdin);
    freopen("milk.out", "w", stdout);

    int n, m, i,j, a,b;
    long long p;

    scanf("%d %d", &n, &m);
    for(i=0; i<m; i++) scanf("%d %d", &a, &b), farmers.push_back(ii(a,b));

    sort(farmers.begin(), farmers.end());

    p=0;
    for(i=0; n>0; i++){
        if(n>=farmers[i].second){
            n-=farmers[i].second;
            p+=farmers[i].first*farmers[i].second;
        }else{
            p+=farmers[i].first*n;
            n=0;
        }
    }
    printf("%lld\n", p);
    return 0;
}
开发者ID:ABHINAVKR,项目名称:ACM,代码行数:25,代码来源:milk.cpp


示例14: main

int main(){
    FILE *f;
    f =fopen("input/OrderingTasks.in", "r");
    
    #ifdef ONLINE_JUDGE
    f = stdin;
    #endif
    
    int m,n;
    while(fscanf(f, "%d %d", &n, &m) == 2 && n){
        g.clear();
        g.assign(n, vi());
        for(int i = 0 ; i < m ; i++){
            int u,v;
            fscanf(f, "%d %d", &u,&v);
            g[u-1].push_back(v-1);
        }
        vi sortedV;
        for(int i = 0 ; i < n ; i++){
            if(!visited[i])
                dfs(i, sortedV);
        }
        memset(visited, 0, sizeof visited);
        for(int i = sortedV.size() -1 ; i >= 0 ; i--){
            printf("%d", sortedV[i] + 1);
            if(i)printf(" ");
            else printf("\n");
        }
    }
    
    return 0;
}
开发者ID:giusevtr,项目名称:problemsolving,代码行数:32,代码来源:OrderingTasks.cpp


示例15: main

int main() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  scanf("%d", &n);
  ll sum = 0;
  for(int i = 0; i < n; ++i) {
    int a, b; scanf("%d %d", &a, &b);
    sum += a;
    s.pb(mp(a, -1));
    s.pb(mp(b, 1));
  }
  sort(s.begin(), s.end());
  ll qtd = 0;
  ll maxi = sum;
  ll p = 0;
  for(int i = 0; i < s.size(); ++i) {
    if(s[i].S == -1) {
      qtd -= s[i].S;
      sum -= s[i].F;
    }
    ll foo = qtd * (ll)s[i].F + sum;
    if(foo > maxi) {
      maxi = foo;
      p = s[i].F;
    }
    if(s[i].S == 1) qtd -= s[i].S;
  }
  printf("%lld %lld\n", p, maxi);
  return 0;
}
开发者ID:juniorandrade1,项目名称:Competitive-Programming,代码行数:30,代码来源:L.cpp


示例16: findBridges

void  findBridges(int u)
{
    dfs_num[u]=dfs_low[u]=dfsNumbercounter++;
    for(int i =0; i < adj[u].size();i++){
        int vizinho = adj[u][i];
        if(dfs_num[vizinho] == DFS_WHITE)
        {
            dfs_parent[vizinho] = u;

            findBridges(vizinho);

            if(dfs_low[vizinho]>dfs_num[u]){
                bridge.push_back(ii(u,vizinho));
                bridge.push_back(ii(vizinho,u));
            }

            else {bridge.push_back(ii(u,vizinho));}

            visitados[u][vizinho]=visitados[vizinho][u]=true;
            dfs_low[u]=min(dfs_low[u],dfs_low[vizinho]);
        }
        else if(vizinho!=dfs_parent[u]){
            dfs_low[u] = min(dfs_low[u],dfs_num[vizinho]);
            if(!visitados[u][vizinho]){
                bridge.push_back(ii(u,vizinho));
                visitados[u][vizinho]=visitados[vizinho][u]=true;
            }
        }
    }
}
开发者ID:lcavalcante,项目名称:AA,代码行数:30,代码来源:main.cpp


示例17: sol

	void sol(){

		if(s2<s1){
			vi t=a;a=b;b=t;
			ll x=s1;s1=s2;s2=x;
			t=ida;ida=idb;idb=t;
			fliped=!fliped;
		}

		if(a.empty() || b.empty())return ;

		if(abs(s1-s2)==0){return ;}

		ll diff = abs(s2 - s1);
		ll Y = diff;
		int x,y;
		x=y=0;
	//	printf("diff = %lld\n",diff);

		for (int i = 0; i < a.size(); ++i) {

			vi::iterator it = lower_bound(b.begin(), b.end(), diff/2 + a[i]);
			int j = it-b.begin();
			if(j && j == b.size())j--;

//			printf("i,j=%d,%d\n",i,j);

			ll ns1 = s1 - a[i] + b[j];
			ll ns2 = s2 - b[j] + a[i];

	//		printf("debug a[%d] = %d b[%d] = %d\n",i,a[i],j,b[j]);
	//		printf("debug ns1 = %lld ns2 = %lld\n",ns1,ns2);
			if(abs(ns1 - ns2) < Y){
				x = i;
				y = j;
	//			printf("debug %d %d\n",x,y);
				Y = abs(ns1 - ns2);
			}
		}



		if(Y<diff){
//			printf("swaping a[%d] b[%d] diff = %lld\n", x,y, Y);
			if(fliped)
				ans.push_back(ii(idb[y],ida[x]));
			else
				ans.push_back(ii(ida[x],idb[y]));
			s1 = s1 - a[x] + b[y];
			s2 = s2 + a[x] - b[y];
		}

//		printf("x,y = %d %d\n",x,y);

		a.erase(move(a,x));
		ida.erase(move(ida,x));
		b.erase(move(b,y));
		idb.erase(move(idb,y));
	}
开发者ID:giusevtr,项目名称:problemsolving,代码行数:59,代码来源:D.cpp


示例18: main

int main(){
	int tc, n, g, u, v;
	cin >> tc;
	while (tc--){
		cin >> n >> g;
		
		AdjList.assign(n, vi());
		for (int i = 0; i < g; ++i){
			cin >> u >> v;
			--u; --v;
			AdjList[u].push_back(v);
		}
		if (n == 0){
			cout << 0 << endl;
			continue;
		}
		dfs_num.assign(n, DFS_WHITE);
		dfs_low.assign(n, 0);
		visited.assign(n, 0);
		scc_weight.assign(n, 0);
		scc_id.assign(n, -1);
		dfsCounter = numSCC = 0;
		for (int i = 0; i < n; i++)
			if (dfs_num[i] == DFS_WHITE)
				tarjanSCC(i);
		
		SccAdj.assign(numSCC, vi());
		for (int u = 0; u < n; ++u)
			for (auto &v : AdjList[u])
				if (scc_id[v] != scc_id[u])
					SccAdj[scc_id[u]].push_back(scc_id[v]);
		

		dfs_num.assign(numSCC, DFS_WHITE);
		topoSort.clear();
		for (int i = 0; i < numSCC; i++)
			if (dfs_num[i] == DFS_WHITE)
				dfs(i);

		vi dist(numSCC, 0);
		int best = 1;
		for (int u = topoSort.size() - 1; u >= 0; --u){
			dist[topoSort[u]] = min(dist[topoSort[u]], scc_weight[topoSort[u]]);
			best = min(best, dist[topoSort[u]]);
			for (auto &v : SccAdj[topoSort[u]]){
				dist[v] = min(dist[v], dist[topoSort[u]] + scc_weight[v]);
				best = min(best, dist[v]);
				
			}
		}
		cout << -best << endl;
	}
}
开发者ID:andresvrl,项目名称:Competitive_Programming,代码行数:53,代码来源:11324+-+The+Largest+Clique.cpp


示例19: main

int main(){
    int t, n, i,j, x,y;
    scanf("%d", &t);
    while(t--){
        scanf("%d", &n);
        ps.clear();
        for(i=0; i<n; i++){ scanf("%d", &x); ps.push_back(ii(x,-1)); }
        for(i=0; i<n; i++){ scanf("%d", &x); ps[i].second=x; }

        sort(ps.begin(), ps.end());
        ys.clear();
        for(i=0; i<n; i++) ys.push_back(ps[i].second);
        printf("%d\n", LIS_Len(ys));
    }
    return 0;
}
开发者ID:ABHINAVKR,项目名称:ACM,代码行数:16,代码来源:BRIDGE.cpp


示例20: main

int main()
{
	int test;
	scanf("%d", &test);
	for(int te=1;te<=test;te++)
	{
		grip.clear();
		data.clear();
		scanf("%d %d", &n, &m);
		for(int i=0;i<n;i++)
		{
			string x;
			cin>>x;
			grip.push_back(x);
		}
		getGraph();
		sol(piii(pii(data[0].first, data[0].second),0));
		int pos=-1;
		for(int i=0;i<4;i++)
			if(d[data[1].first][data[1].second][i] !=-1)
			{
				pos=i;
				break;
			}
		if(pos>=0)
			printf("Case #%d: %d\n", te,d[data[1].first][data[1].second][pos]);
		else
			printf("Case #%d: impossible\n", te);
	}
}
开发者ID:RodolfoQuispeC,项目名称:CPproblemsSolved,代码行数:30,代码来源:LaserMaze.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ vint类代码示例发布时间:2022-05-31
下一篇:
C++ viewer_media_t类代码示例发布时间: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