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

静态网站可以做哪些内容近期国内新闻摘抄

静态网站可以做哪些内容,近期国内新闻摘抄,我买了一个域名怎么做网站,网络公司做网站价格【题目来源】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.tdrn.cn/news/329.html

相关文章:

  • 电子邮箱网站建设东莞seo网站制作报价
  • 做业务查牙医诊所一般用什么网站公司网站建设开发
  • 建站之星怎么免费做网站如何接广告赚钱
  • wordpress怎么绑定域名奉化网站关键词优化费用
  • 创新的响应式网站建设百度网站电话是多少
  • github网站注册账号怎么做推广网站平台
  • 怎么用自己的电脑做网站涟源网站seo
  • 专做智能化施工的网站拉新充场app推广平台
  • 江西 网站制作推广方式营销方案
  • 兰州网站怎么建设seo外包服务专家
  • java编程代码大全优化水平
  • 合肥瑶海区寒假兼职工网站建设网站建设方案书模板
  • 政府网站改版建设报告window优化大师
  • 济南做网站0531soso免费投放广告的平台
  • 淮安 做网站 app广州公关公司
  • 安徽做政府网站的企业深圳最好的外贸seo培训
  • 做网站需要什么语言如何找外包的销售团队
  • 南昌网站建设方案推广网络推广软文
  • 乐清 网站建设qq群推广方法
  • 乐清建网站哪家强软文300字介绍商品
  • 天津做网站找哪家公司好市场监督管理局是干什么的
  • 百度手机网站提交为什么sem的工资都不高
  • 企业网站也需要在公安做备案么广州线上教学
  • 网站建设费用贵不贵软文推广发布
  • 重庆免费注册推广网站杭州seo排名优化外包
  • 设计网站推荐理由惠州网站seo
  • 短视频网站平台怎么做的嘉兴seo网络推广
  • 静态网站跟动态新闻稿范文300字
  • 北京华诚传媒有限公司官方网站q群排名优化软件
  • 做网站专用素材重庆seo技术教程