【链接】: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. IIS相关服务和无法启动服务W3SVC错误提示

    首先,打开“服务”查看下面的服务是否启动.(下面的两个服务就是跟IIS相关的服务,计算机(右键)->管理->服务和应用程序->服务) Windows Process Activati ...

  2. 【Multiply Strings】cpp

    题目: Given two numbers represented as strings, return multiplication of the numbers as a string. Note ...

  3. leetcode_day02

    任务二:删除排序数组中的重复项 原文链接:https://leetcode-cn.com/problems/remove-duplicates-from-sorted-array/ 最开始的解决思路: ...

  4. python基础——字典dict

    1.概念: (1)字典dict,是一系列的键—值对.每个键key都和一个值value相映射.(字典是python中唯一的映射类型.) (2)每一项item,是一个键值对key—value对. (3)键 ...

  5. shell之dialog提示窗口

    dialog 提示窗口 1.msgbox     dialog --msgbox text 20 10 2.yesno     dialog --title "Please answer&q ...

  6. winform 使用Anchor属性进行界面布局

    每个控件的定位方法: 一.使用Anchor: Anchor分为Left.Top.Right.Bottom四个属性. 它们的含义如下: Top——表示控件中与父窗体(或父控件)相关的顶部应该保持固定. ...

  7. 【python】用python爬取中科院院士简介信息

    018/07/09 23:43 项目名称:爬取中科院871个院士的简介信息 1.爬取目的:中科院871个院士的简介信息 2.爬取最终结果: 3.具体代码如下: import re # 不用安装(注意! ...

  8. 201621123033 《Java程序设计》第7周学习总结

    1. 本周学习总结 1.1 思维导图:Java图形界面总结 2.书面作业 1. GUI中的事件处理 1.1 写出事件处理模型中最重要的几个关键词. 事件源:事件发生的场所,具体指各个组件. 事件:组件 ...

  9. Hexo安装配置详解

    原文 http://blog.csdn.net/tonydandelion2014/article/details/61615898 http://www.joryhe.com/2016-06-06- ...

  10. Vue,watch观察对象中的某个属性的变化

    你只需要属性这样写,用引号引起来