DescriptionGiven the number of n, it is required to remove the duplicate, only the first occurrence of the number. For example, the number given is 1 2 18 3 3 19 2 3 6 5 4, of which 2 and 3 have duplicates, the result of removal is 1 2 18 3 19 6 5 4.InputEnter the first behavior positive integer t, which indicates that there is a T group of data. Next, each set of data consists of two rows, the first positive integer n, which indicates the number of N. The second behavior is to go to a heavy n positive integer.OutputFor each set of data, the output line is the number left after the deduplication, separated by a space between the numbers.Sample Input2
11
1 2 18 3 3 19 2 3 6 5 4
6
1 2 3 4 5 6
Sample Output1 2 18 3 19 6 5 4
1 2 3 4 5 6
HINT
For 30% of the data, 1 <= N <= 100, the number given is not greater than 100, are non-negative integers;
For 50% of the data, 1 <= N <= 10000, the number given is not greater than 10000, are non-negative integers;
For 100% of the data, 1 <= N <= 50000, given the number within the 32-bit signed integer range.
Tips :
because of the large amount of data, students using C + + use scanf and printf for input and output operations to avoid wasting unnecessary time.
SourceSolution
Set can
There are no spaces at the end of the line
1#include <bits/stdc++.h>2 using namespacestd;3 Set<int>S;4 intMain ()5 {6 intT, N, A;7scanf"%d", &t);8 while(t--)9 {Tenscanf"%d%d", &n, &a); One s.clear (), S.insert (a); Aprintf"%d", a); - for(inti =2; I <= N; i++) - { thescanf"%d", &a); - if(S.find (a) = =s.end ()) - { - S.insert (a); +printf"%d", a); - } + } APuts""); at } - return 0; -}View Code
[BZOJ2761] [JLOI2011] Non-repeating number (set)