【链接】:CF978A

【分析】:逆向思考+标记数组去重

【代码】:

#include<bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
#define ms(a,b) memset(a,b,sizeof(a))
#define rep(i,a,b) for(int i=(a); i<(b); i++)
//#define run(i,a,b) for(int i=(a); i<=(b); i++)
const int N = 1e5+5;
#define ll long long
int n; int v[N];
int b[N];
int a[N];
set<int> st;
vector<int> vt;
int main()
{
cin>>n;
rep(i,0,n)
{
cin>>a[i];
st.insert(a[i]);
}
cout<<st.size()<<endl;
for(int i=n-1;i>=0;i--)
{
if(v[a[i]]==0)
{
vt.push_back(a[i]);
}
v[a[i]]=1;
}
for(int i=st.size()-1;i>=0;i--)
{
printf("%d ",vt[i]);
}
}

CF978A Remove Duplicates【数组操作/STL】的更多相关文章

  1. [LeetCode] Remove Duplicates from Sorted Array II 有序数组中去除重复项之二

    Follow up for "Remove Duplicates":What if duplicates are allowed at most twice? For exampl ...

  2. [LeetCode] Remove Duplicates from Sorted Array 有序数组中去除重复项

    Given a sorted array, remove the duplicates in place such that each element appear only once and ret ...

  3. leetCode 26.Remove Duplicates from Sorted Array(删除数组反复点) 解题思路和方法

    Remove Duplicates from Sorted Array Given a sorted array, remove the duplicates in place such that e ...

  4. [LeetCode] 80. Remove Duplicates from Sorted Array II ☆☆☆(从有序数组中删除重复项之二)

    https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii/discuss/27976/3-6-easy-lines-C% ...

  5. [LeetCode] 26. Remove Duplicates from Sorted Array ☆(从有序数组中删除重复项)

    [LeetCode] Remove Duplicates from Sorted Array 有序数组中去除重复项 描述 Given a sorted array nums, remove the d ...

  6. 【数组】Remove Duplicates from Sorted Array II

    题目: Follow up for "Remove Duplicates":What if duplicates are allowed at most twice? For ex ...

  7. LeetCode OJ:Remove Duplicates from Sorted Array II(移除数组中的重复元素II)

    Follow up for "Remove Duplicates":What if duplicates are allowed at most twice? For exampl ...

  8. [LeetCode] 80. Remove Duplicates from Sorted Array II 有序数组中去除重复项之二

    Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twic ...

  9. [LeetCode] 26. Remove Duplicates from Sorted Array 有序数组中去除重复项

    Given a sorted array nums, remove the duplicates in-place such that each element appear only once an ...

随机推荐

  1. 以+scheduledTimerWithTimeInterval...的方式触发的timer,在滑动页面上的列表时,timer会暂定回调,为什么?如何解决?

    这里强调一点:在主线程中以+scheduledTimerWithTimeInterval...的方式触发的timer默认是运行在NSDefaultRunLoopMode模式下的,当滑动页面上的列表时, ...

  2. python之路——网络编程

    一.楔子 你现在已经学会了写python代码,假如你写了两个python文件a.py和b.py,分别去运行,你就会发现,这两个python的文件分别运行的很好.但是如果这两个程序之间想要传递一个数据, ...

  3. makefile规则整理

    makefile规则整理 实际开发中,makefile改的多,写的少. 为了后面不要在编译链接这种地方花费太多的时间,在这里系统性的整理其规则: 基本格式 TARGET : PREREQUISITES ...

  4. c语言版贪吃蛇小游戏

    编译环境:windows 7 64位 编译工具:codeblocks 13.12 备注:未使用graphics.h 声明:个人原创,未经允许,禁止转载!!! 数据结构:双向链表 1.程序未使用grap ...

  5. 爬虫:Scrapy9 - Feed exports

    实现爬虫时最经常提到的需求就是能合适的保存爬取到的数据,或者说,生成一个带有爬取数据的“输出文件”(通常叫“输出 feed”),来供其它系统使用. Scrapy 自带了 Feed 输出,并且支持多种序 ...

  6. python基础--用python执行系统命令

    from os import system print(system('ping www.baidu.com'))

  7. Extjs 4 小记

    ////////////////////////////////////---Ajax 等待提示消息---/////////////////////////////////////////////// ...

  8. 主流 NoSQL 数据库对比

    HBase HBase 是 Apache Hadoop 中的一个子项目,属于 bigtable 的开源版本,所实现的语言为Java(故依赖 Java SDK).HBase 依托于 Hadoop 的 H ...

  9. Oracle 根据逗号分隔字符串 同时记录一波坑

    报表需要过滤掉不需要的数据,由于报表是根据零件编号来统计,需要过滤掉不合格品,只能根据关联的物料编码(零件编号)来过滤,只能通过not in来过滤,但是天真的我却用下面代码来当子查询: b.part_ ...

  10. box-pack

    box-pack表示父容器里面子容器的水平对齐方式,可选参数如下所示: start | end | center | justify <article class="wrap" ...