题解 P4305 【[JLOI2011]不重复数字】

ShineEternal

2019-08-13 21:48:25

Solution

# 题目链接: https://www.luogu.org/problem/P4305 # 分析: 看到没有stl的map,那就补充一篇 这道题直接把数字往map里面一问看看之前有没有人进来过,没有就输出,顺便标记自己进来过。 顺便提醒要在输出的时候一边输出一边判断(很好理解) # code: ```cpp #include<cstdio> #include<map> using namespace std; map<int,int>m; int a[50005]; int main() { int T; scanf("%d",&T); while(T--) { m.clear(); int n; scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d",&a[i]); } for(int i=1;i<=n;i++) { if(m[a[i]]==0) { m[a[i]]=1; printf("%d ",a[i]); } } printf("\n"); } return 0; } ```