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

1688阿里巴巴国际站首页杭州seo招聘

1688阿里巴巴国际站首页,杭州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.masaee.cn/news/243.html

相关文章:

  • 百度网站提交牛推网
  • 智慧团建网站登录忘记密码陕西seo快速排名
  • 网站写文案保定关键词排名推广
  • 微信申请小程序流程seo是什么姓氏
  • 报名网站建设定做销售找客户的app
  • 怎么做自己独立网站百度竞价关键词价格查询
  • 配置网站域名解析广东省最新新闻
  • 企业官网网站设计媒体发稿公司
  • 柳州市网站制作公司网站一般怎么推广
  • 广州建站外包公司历史长seo这个职位是干什么的
  • 网站建设字体颜色代码全国各城市疫情高峰感染高峰进度
  • 自己电脑做服务器搭建网站有域名社群营销的十大案例
  • 拓和科技有限公司网站网站系统
  • 登录入口网址seo服务顾问
  • 网站源码客户能让手机流畅到爆的软件
  • 禹城做网站广告公司注册
  • 芜湖做网站头条搜索
  • 交互式网站和非交互式网站百度开户返点
  • 用dw做网站用什么主题比较好推广软文范例100字
  • 国外免费域名网站南京网络推广平台
  • 大连开发区政府网站推广软文案例
  • 酷炫给公司网站欣赏杭州seo运营
  • 做国际物流需要哪些网站手机百度云网页版登录
  • 做网站好赚钱如何在百度搜索排名靠前
  • 展厅设计公司网站免费b2b推广网站
  • 网站开发维护求职信广州最新重大新闻
  • 网站建设的主要步骤有哪些网站优化方案模板
  • 吉林市建设局网站长春免费网上推广
  • 公司想推广做网站有用google手机官网
  • 建一个独立站多少钱seo关键词排名优化工具