NC16669 明明的随机数unique或者set去重
题意: 给定一个数组,打印排序去重后的数组
- 用set可以
- 用unique也可以
#ifdef debug
#include <time.h>
#include "/home/majiao/mb.h"
#endif
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#define MAXN ((int)1e5+7)
#define ll long long int
#define INF (0x7f7f7f7f)
#define QAQ (0)
using namespace std;
#ifdef debug
#define show(x...) \ do { \ cout << "\033[31;1m " << #x << " -> "; \ err(x); \ } while (0)
void err() { cout << "\033[39;0m" << endl; }
#endif
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
int n, m, Q, K, a[MAXN];
int main() {
#ifdef debug
freopen("test", "r", stdin);
clock_t stime = clock();
#endif
scanf("%d ", &n);
for(int i=1; i<=n; i++) scanf("%d ", a+i);
sort(a+1, a+1+n);
m = std::unique(a+1, a+1+n)-(a+1);
printf("%d\n", m);
for(int i=1; i<=m; i++) {
printf("%d%c", a[i], i==n?'\n':' ');
}
#ifdef debug
clock_t etime = clock();
printf("rum time: %lf 秒\n",(double) (etime-stime)/CLOCKS_PER_SEC);
#endif
return 0;
}