bzoj 2761[JLOI 2011]数字を繰り返さない
5520 ワード
原題リンク:http://www.lydsy.com/JudgeOnline/problem.php?id=2761
簡単な問題でstlを練習します.の
View Code
簡単な問題で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 ? ' ' : '
');
28 }
29 }
30 return 0;
31 }
View Code