给你一个1~n排好的数组,每次提一个数到最前面,问你最后形成的序列。

就把他的输入顺序倒过来输出即可。没出现过的再按原序输出。

#include<cstdio>
using namespace std;
int n,m,path[200010],a[100010],e;
bool vis[200010];
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=m;++i){
scanf("%d",&a[i]);
}
for(int i=m;i>=1;--i){
if(!vis[a[i]]){
vis[a[i]]=1;
path[++e]=a[i];
}
}
for(int i=1;i<=n;++i){
if(!vis[i]){
path[++e]=i;
}
}
for(int i=1;i<=n;++i){
printf("%d\n",path[i]);
}
return 0;
}

【思路】Aizu - 1367 - Rearranging a Sequence的更多相关文章

  1. bzoj 1367 [ Baltic 2004 ] sequence —— 左偏树

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1367 好题啊!论文上的题: 论文上只给出了不下降序列的求法: 先考虑特殊情况,如果原序列上升 ...

  2. Trainning Guide的代码

    今天无意间找到了训练指南的网上代码,都是刘汝佳写的,在这. 今天在做这题1400 - "Ray, Pass me the dishes!",我写的线段树的思路跟上次的Frequen ...

  3. [LeetCode] 115. Distinct Subsequences_ Hard tag: Dynamic Programming

    Given a string S and a string T, count the number of distinct subsequences of S which equals T. A su ...

  4. [Tensorflow] RNN - 02. Movie Review Sentiment Prediction with LSTM

    From: Predicting Movie Review Sentiment with TensorFlow and TensorBoard Ref: http://www.cnblogs.com/ ...

  5. BZOJ 1367 [Baltic2004]sequence 解题报告

    BZOJ 1367 [Baltic2004]sequence Description 给定一个序列\(t_1,t_2,\dots,t_N\),求一个递增序列\(z_1<z_2<\dots& ...

  6. 【BZOJ 1367】 1367: [Baltic2004]sequence (可并堆-左偏树)

    1367: [Baltic2004]sequence Description Input Output 一个整数R Sample Input 7 9 4 8 20 14 15 18 Sample Ou ...

  7. BZOJ 1367: [Baltic2004]sequence [可并堆 中位数]

    1367: [Baltic2004]sequence Time Limit: 20 Sec  Memory Limit: 64 MBSubmit: 1111  Solved: 439[Submit][ ...

  8. codeforce gym/100495/problem/K—Wolf and sheep 两圆求相交面积 与 gym/100495/problem/E—Simple sequence思路简述

    之前几乎没写过什么这种几何的计算题.在众多大佬的博客下终于记起来了当时的公式.嘚赶快补计算几何和概率论的坑了... 这题的要求,在对两圆相交的板子略做修改后,很容易实现.这里直接给出代码.重点的部分有 ...

  9. bzoj 1367: [Baltic2004]sequence

    1367: [Baltic2004]sequence Time Limit: 20 Sec  Memory Limit: 64 MB Description Input Output 一个整数R Sa ...

随机推荐

  1. Python 关于时间和日期函数使用 -- (转)

    python中关于时间和日期函数有time和datatime   1.获取当前时间的两种方法: import datetime,time now = time.strftime("%Y-%m ...

  2. 【自己练习】linux常见命令——(六)

    菜鸟教程命令大全 http://www.runoob.com/linux/linux-command-manual.html 命令大全:      http://man.linuxde.net/ ta ...

  3. perl 在win下输出中文乱码问题

    use utf8; my $name = '你好'; binmode(STDOUT, ":encoding(gbk)"); print $name,"\n"; ...

  4. redis基础之开机自启动和监听(二)

    redis安装好后,每次手动启动很不方便,配置开机自启动. 方法一:设置启动命令到/etc/rc.d/rc.local rc.local文件是系统全局脚本文件,会在其他开机进程脚本文件执行完毕后执行该 ...

  5. 【EverydaySport】健身笔记——动态牵拉

    动态牵拉,包含了动态和牵拉两个概念.动态牵拉要求牵拉的过程要伴随着走路,即行进中牵拉,动态牵拉不仅可以使得肌肉得到延展,还可以激活肌肉协同工作,发展协调性.灵活性.进行动态牵拉时每个动作要进行5~10 ...

  6. Git常规配置与基本用法

    Git环境配置 一. 全局配置 1. 配置文件 git全局配置文件.gitconfig默认在当前系统用户文件夹下,window可运行%USERPROFILE%查找,Mac系统在cd ~查找. 具体配置 ...

  7. v4l2驱动编写篇【转】

    转自:http://blog.csdn.net/michaelcao1980/article/details/53008418 大部分所需的信息都在这里.作为一个驱动作者,当挖掘头文件的时候,你可能也 ...

  8. JS中Unix时间戳转换日期格式

    <!doctype html> <html> <head> <title>Unix时间戳转换成日期格式</title> <script ...

  9. 1438. Shopaholic

    Constraints Time Limit: 1 secs, Memory Limit: 32 MB Description Lindsay is a shopaholic. Whenever th ...

  10. js中常用的数组方法

    在数组的尾部增加或删除某个元素:push() 和 pop() push() : 在数组的尾部追加一个或多个元素,并返回数组的长度 pop():在数组的尾部删除一个元素,并返回被删除项 var arr ...