当前位置: 首页 > news >正文

后台去掉 wordpress新闻石狮seo

后台去掉 wordpress新闻,石狮seo,做外贸哪些国外网站可以推广,成都十大著名景点当时没想到可以用队列来做&#xff0c;就傻傻的模拟了&#xff0c;用cur存当前轮的id&#xff0c;这个id对应的是order的下标&#xff0c;这里有个求rank的技巧就是当前轮没有晋级的rank为&#xff08;当前轮的组数1&#xff09; 模拟&#xff1a; #include<bits/stdc.h&g…

当时没想到可以用队列来做,就傻傻的模拟了,用cur存当前轮的id,这个id对应的是order的下标,这里有个求rank的技巧就是当前轮没有晋级的rank为(当前轮的组数+1)

模拟:

#include<bits/stdc++.h>
using namespace std;
struct node{int id,w,rk=0;
};
vector<node> vec;
vector<int> order,cur; //cur用来记录当前晋级的组里面的id,对应order数组的下标
int np,ng;
bool cmp(node&a, node& b){return a.rk>b.rk;
}
int main(){scanf("%d%d",&np,&ng);vec.resize(np);order.resize(np);cur.resize(np);for(int i=0;i<np;i++){scanf("%d",&vec[i].w);vec[i].id=i;cur[i]=i;}for(int i=0;i<np;i++)scanf("%d",&order[i]);if(cur.size()==1){printf("1");return 0;}while(cur.size()>1){int start=0;vector<int> temp;int numg; //当前分组数if(cur.size()%ng!=0) numg=cur.size()/ng+1;else numg=cur.size()/ng;while(start<cur.size()){int max=-1,maxi=0;for(int i=start;i<start+ng&&i<cur.size();i++){vec[order[cur[i]]].rk=numg+1;if(max<vec[order[cur[i]]].w){max=vec[order[cur[i]]].w;maxi=i;}}vec[order[cur[maxi]]].rk=numg==1?1:numg+1;temp.push_back(cur[maxi]);start+=ng;}cur=temp;}sort(vec.begin(),vec.end(),[](node& a,node& b){return a.id<b.id;});for(int i=0;i<vec.size();i++)printf(i==0?"%d":" %d",vec[i].rk);return 0;
}

柳神的队列做法:

#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;
struct node {int weight, index, rank, index0;
};
bool cmp1(node a, node b) {return a.index0 < b.index0;
}
int main() {int n, g, num;scanf("%d%d", &n, &g);vector<int> v(n);vector<node> w(n);for(int i = 0; i < n; i++)scanf("%d", &v[i]);for(int i = 0; i < n; i++) {scanf("%d", &num);w[i].weight = v[num];w[i].index = i;w[i].index0 = num;}queue<node> q;for(int i = 0; i < n; i++)q.push(w[i]);while(!q.empty()) {int size = q.size();if(size == 1) {node temp = q.front();w[temp.index].rank = 1;break;}int group = size / g;if(size % g != 0)group += 1;node maxnode;int maxn = -1, cnt = 0;for(int i = 0; i < size; i++) {node temp = q.front();w[temp.index].rank = group + 1;q.pop();cnt++;if(temp.weight > maxn) {maxn = temp.weight;maxnode = temp;}if(cnt == g || i == size - 1) {cnt = 0;maxn = -1;q.push(maxnode);}}}sort(w.begin(), w.end(), cmp1);for(int i = 0; i < n; i++) {if(i != 0) printf(" ");printf("%d", w[i].rank);}return 0;
}

http://www.yidumall.com/news/6135.html

相关文章:

  • 郑州网络营销排名seo点击排名
  • 深圳网站建设 独查询网址域名
  • 购物商城外贸网站建设北京网站推广服务
  • 做网站怎么弄模板宿州百度seo排名软件
  • 可以做网络兼职的网站网络营销推广要求
  • 做电影网站的成本建网站要多少钱
  • 中国站长站官网百度指数分析平台
  • 手机好在百度做网站吗重庆专业做网站公司
  • 国外网络推广哪家公司好重庆seo博客
  • 小程序加盟的骗局连云港seo优化公司
  • 整站seoseo优化新闻株洲最新
  • b2b电子商务网站调研报告1000字免费2023新闻热点摘抄
  • 犀牛做网站的公司网站设计制作培训
  • 上海专业的网站建设公司哪家好宁波百度快照优化排名
  • 湖南健康卡app郑州seo地址
  • 婚礼网搜索排名优化公司
  • 网站建设学什么软件外链群发软件
  • 网站上传权限问题优秀网页设计赏析
  • wordpress站群作用google开户
  • 信阳网站建设哪家好常德网站优化公司
  • 工商注册查询公司名称临沂seo公司
  • wordpress蜜蜂采集仁茂网络seo
  • 有些公司做网站比较好的seo优化一般包括哪些内容()
  • 登录网站后没有转页面网页制作公司哪家好
  • svn教程图文详解 - 青岛网站建设网站排名优化系统
  • 邢台企业做网站找谁seo工作室
  • 徐城乡建设局网站百度指数的基本功能
  • wordpress下不了插件吗苏州seo关键词优化价格
  • 怎么制作网站视频下拉词排名
  • 怎样查看网站是用什么cms 做的在线网页编辑平台