-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSearching16.cpp
More file actions
46 lines (40 loc) · 1.02 KB
/
Copy pathSearching16.cpp
File metadata and controls
46 lines (40 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include<iostream>
#include<algorithm>
#include<vector>
int main(){
int t;
std::cin>>t;
while (t--)
{
int N1,N2,N3;
std::cin>>N1>>N2>>N3;
std::vector<double>::iterator it;
std::vector<double>D(N1);
std::vector<double>res(N1);
double A[N1],B[N2],C[N3];
for (int i = 0; i < N1; i++)
{
std::cin>>A[i];
}
for (int i = 0; i < N2; i++)
{
std::cin>>B[i];
}
for (int i = 0; i < N3; i++)
{
std::cin>>C[i];
}
it = std::set_intersection(A,A+N1,B,B+N2,D.begin());
D.resize(it - D.begin());
it = std::set_intersection(D.begin(),D.end(),C,C+N3,res.begin());
res.resize(it - res.begin());
for (it = res.begin(); it != res.end(); it++)
{
std::cout<<*it<<" ";
}
if(res.empty())
std::cout<<-1;
std::cout<<std::endl;
}
return 0;
}