-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1920.cpp
More file actions
38 lines (29 loc) · 716 Bytes
/
1920.cpp
File metadata and controls
38 lines (29 loc) · 716 Bytes
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
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
vector<int> v;
bool binarySearch(int start, int end, int target){
if(start > end) return false;
int mid = (start+end)/2;
if(target == v[mid]) return true;
if(target > v[mid]) return binarySearch(mid+1, end, target);
else return binarySearch(start, mid-1, target);
}
int main(){
cin.tie(NULL);
ios_base::sync_with_stdio();
int N, M, a;
cin >> N;
for(int i=0; i<N; i++){
cin >> a;
v.push_back(a);
}
sort(v.begin(), v.end());
cin >> M;
for(int i=0; i<M; i++){
cin >> a;
cout << (binarySearch(0, N-1, a)?1:0) << '\n';
}
}