【链接】: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. iOS程序执行顺序和UIViewController 的生命周期(整理)

    说明:此文是自己的总结笔记,主要参考: iOS程序的启动执行顺序 AppDelegate 及 UIViewController 的生命周期 UIView的生命周期 言叶之庭.jpeg 一. iOS程序 ...

  2. mac虚拟机上(centos系统)怎样实现共享本机文件

    首先加载vboxadditions,可以从https://download.virtualbox.org/virtualbox/下载,记得一定要跟virtualBox版本对应 然后打开virtualb ...

  3. Python全栈工程师(列表、拷贝)

    ParisGabriel     感谢 大家的支持  你们的阅读评价就是我最好的更新动力  我会坚持吧排版做的越来越好      每天坚持 一天一篇 点个订阅吧  灰常感谢    当个死粉也阔以 Py ...

  4. Leetcode with Python -> Sort

    349. Intersection of Two Arrays Given two arrays, write a function to compute their intersection. Ex ...

  5. 软工实践 - 第十九次作业 Alpha 冲刺 (10/10)

    队名:起床一起肝活队 组长博客:https://www.cnblogs.com/dawnduck/p/10046955.htmlz 作业博客:班级博客本次作业的链接 组员情况 组员1(队长):白晨曦 ...

  6. .Net MVC断点进不去

    .Net MVC断点进不去 1.httpget  httppost 2.启动项设为UI 3.基于页面没错误的情况下

  7. hdu 3354 Probability One

    Probability One Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  8. [Codeforces Round #516 (Div. 2, by Moscow Team Olympiad) ](A~E)

    A: 题目大意:给你$a,b,c$三条边,可以给任意的边加任意的长度,求最少共加多少长度使得可以构成三角形 题解:排个序,若可以组成,输出$0$,否则输出$c-a-b+1(设a\leqslant b\ ...

  9. JZOJ 5279 香港记者

    一句话题意:一个带点权边权的无向图,输出从1号点到n号点的最短路中字典序最小的一条路径 样例输入: 8 9 1 2 3 4 5 6 7 8 1 2 2 2 3 3 3 8 3 1 4 3 4 5 2 ...

  10. java的struts2整理

    readbook:struts2 先说一下struts1:    struts1使用model II 模式开发,即jsp+java bean+servlet    再说它的缺陷:    1.表现层支持 ...