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

wordpress s7seo顾问服务

wordpress s7,seo顾问服务,精美个人主页,wordpress点击文字弹出层【题目来源】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.yidumall.com/news/83084.html

相关文章:

  • 怎么推广一个网站今日热点事件
  • 九江有哪些免费推广网站搜索优化指的是什么
  • 做网站有哪些类型在线网站建设
  • dede wap网站模板下载seo网站关键词优化排名
  • 烟台百度网站建设搜索引擎技术包括哪些
  • wordpress产品批量导入廊坊seo排名公司
  • 软件开发网站开发副业百度搜索引擎平台
  • 农药放行单在哪个网站做上海百度seo网站优化
  • 域名可以绑定几个网站北京厦门网站优化
  • 营销网站开发找哪家来宾网站seo
  • 重庆网站开发企业手机优化什么意思
  • 如何免费自做企业网站百度经验怎么赚钱
  • 中组部 两学一做网站赣州网站seo
  • wordpress 前后台都进不去公众号关键词排名优化
  • 如何将aaa云主机做网站佛山做网站建设
  • 网站js 做日历网站提交收录入口
  • 大连哪个公司做网站好百度公司总部在哪里
  • 网站背景设计制定营销推广方案
  • 广州萝岗区网站建设seo查询 站长工具
  • page做网站seo准
  • 政府网站设计有什么要点淘宝指数查询入口
  • 网站建设案例如何宁波做seo推广企业
  • 网站回头率谷歌seo搜索引擎优化
  • 竞价移动网站线下推广方法及策略
  • 网站建设深圳网络优化论文
  • 养生网站建设免费网址百度刷排名
  • 以下不是网站开发语言的哪项长春seo排名扣费
  • 做cad室内平面图的家具素材网站app推广平台网站
  • 直播网站创做营销方案怎么写模板
  • 动态网站制作费用近一周新闻热点事件