bzoj 2761[JLOI2011]不重复数字

原题链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2761

简单题, 练习一下stl。。

 1 #include<algorithm>

 2 #include<iostream>

 3 #include<cstdlib>

 4 #include<cstdio>

 5 #include<vector>

 6 #include<set>

 7 using std::set;

 8 using std::vector;

 9 int main() {

10 #ifdef LOCAL

11     freopen("in.txt", "r", stdin);

12     freopen("out.txt", "w+", stdout);

13 #endif

14     int t, n, v;

15     scanf("%d", &t);

16     while (t--) {

17         set<int> ret;

18         vector<int> ans;

19         scanf("%d %d", &n, &v);

20         ret.insert(v), ans.push_back(v);

21         for (int i = 1; i < n; i++) {

22             scanf("%d", &v);

23             if (!ret.count(v)) ret.insert(v), ans.push_back(v);

24         }

25         n = ans.size();

26         for (int i = 0; i < n; i++) {

27             printf("%d%c", ans[i], i < n - 1 ? ' ' : '\n');

28         }

29     }

30     return 0;

31 }
View Code

 

你可能感兴趣的:(ZOJ)