SET
-
bzoj2761: [JLOI2011] Unique numbers
- This problem. . .
- count () usage, the return value is the number of times this occurs, it will only appear 0 and 1 in the set where this can determine whether a value is in the set appeared in
- Code
1 #include <bits/stdc++.h> 2 #define nmax 50005 3 4 using namespace std; 5 int n,in; 6 7 int main(){ 8 int t; 9 scanf("%d",&t); 10 while(t--){ 11 set <int> st; 12 scanf("%d",&n); 13 scanf("%d",&in); 14 printf("%d",in); 15 st.insert(in); 16 for (int i=1; i<n; i++) { 17 scanf("%d",&in); 18 if(st.count(in)) continue; 19 printf(" %d",in); 20 st.insert(in); 21 } 22 printf("\n"); 23 } 24 return 0; 25 }