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

wordpress s7seo顾问服务 品达优化

wordpress s7,seo顾问服务 品达优化,电商官方网站,论坛类的网站怎样做【题目来源】https://www.lanqiao.cn/problems/3255/learning/【题目描述】给定按从小到大的顺序排列的数字 1 到 n,随后对它们进行 m 次操作,每次将一个数字 x 移动到数字 y 之前或之后。请输出完成这 m 次操作后它们的顺序。【输入格式】第一行为两个数…

【题目来源】
https://www.lanqiao.cn/problems/3255/learning/

【题目描述】
给定按从小到大的顺序排列的数字 1 到 n,随后对它们进行 m 次操作,每次将一个数字 x 移动到数字 y 之前或之后。请输出完成这 m 次操作后它们的顺序。

【输入格式】
第一行为两个数字 n, m,表示初始状态为 1 到 n 的从小到大排列,后续有 m 次操作。
第二行到第 m+1 行,每行三个数 x, y, z。当 z=0 时,将 x 移动到 y 之后;当 z=1 时,将 x 移动到 y 之前。


【输出格式】
一行,n 个数字,中间用空格隔开,表示 m 次操作完成后的排列顺序。

【输入样例】
5 3
3 1 0
5 2 1
2 1 1

【输出样例】
2 1 3 5 4

【算法分析】
★ 在大多数情况下,可以直接使用 C++ 中的 STL list,而不需手写链表。通过这种方式完成的代码通常更简洁。本例代码中将会使用 list<int>::iterator it=find(ls.begin(),ls.end(),y); 得到 y 的位置。

★ STL list:https://cplusplus.com/reference/list/
(1)
size():Returns the number of elements in the list container.
(2)
empty():Returns whether the list container is empty (i.e. whether its size is 0).
(3)
push_front():Inserts a new element at the beginning of the list, right before its current first element. 
(4)
push_back():Adds a new element at the end of the list container, after its current last element. 
(5)
pop_front():Removes the first element in the list container, effectively reducing its size by one. 
(6)
pop_back():Removes the last element in the list container, effectively reducing the container size by one.
(7)
front():Returns a reference to the first element in the list container.
(8)
back():Returns a reference to the last element in the list container.
(9)
reverse():Reverses the order of the elements in the list container.
(10)
insert():The container is extended by inserting new elements before the element at the specified position.
(11)
erase():Removes from the list container either a single element (position) or a range of elements ([first,last)).
(12)
unique():Notice that an element is only removed from the list container if it compares equal to the element immediately preceding it. Thus, this function is especially useful for sorted lists.

【算法代码】

#include <bits/stdc++.h>
using namespace std;int main() {int n,m;cin>>n>>m;list<int> ls;for(int i=1; i<=n; i++) {ls.push_back(i);}while(m--) {int x,y,z;cin>>x>>y>>z;ls.remove(x);list<int>::iterator it=find(ls.begin(),ls.end(),y);if(z==0) ls.insert(++it,x);if(z==1) ls.insert(it,x);}for(auto i:ls) cout<<i<<" ";cout<<endl;return 0;
}/*
in:
5 3
3 1 0
5 2 1
2 1 1out:
2 1 3 5 4
*/



【参考文献】
https://blog.csdn.net/mc10141222/article/details/123674677
https://cplusplus.com/reference/list/list/



 

http://www.ds6.com.cn/news/48009.html

相关文章:

  • 江苏建设网站公司app推广引流方法
  • 苏州论坛型网站建设阿里seo排名优化软件
  • 公司微网站怎么建设网址大全浏览器app
  • 上海市工程建设协会网站seo网站诊断
  • wordpress左图右字夫唯seo
  • wordpress怎么采集常州网站优化
  • wordpress可以做电影网站吗个人网站免费制作平台
  • 长沙县 网站建设室内设计网站
  • 制作网站用c#做前台单页网站设计
  • 网站开发可行性分析报告范文广州seo工作
  • 外国做网站的平台沧州网站seo
  • 网站基础模板推广优化师
  • iis6.0如何做网站301目前最新的营销模式有哪些
  • 怎么建设h5网站app地推网
  • 用java做的网站有哪些内容推广普通话活动方案
  • 楼梯 技术支持 东莞网站建设品牌营销策划公司排名
  • 怎么上国外购物网站郑州网站优化seo
  • 养殖企业网站云南网络营销公司
  • 宁夏建设技术职业学院官方网站济南seo网站排名优化工具
  • 用ps怎么做网站导航条怎么做谷歌推广怎么做最有效
  • 做网站用的图片分辨率优秀网站设计
  • 如何更新网站seo优化内页排名
  • 中国建设银行企业官网站搜索关键词的软件
  • 网络管理软件app潍坊seo外包平台
  • dw做网站步骤揭阳市seo上词外包
  • 美工做网站是怎么做百度关键词刷排名教程
  • 网站ip被屏蔽怎么办郑州网站seo服务
  • 公司注册网站官网网络营销工程师
  • 水滴保险官方网站惠州百度seo地址
  • 商业网站建设目标新闻平台发布