#include <iostream>
#include <algorithm>
using namespace std;
bool binarysearch(int arr[], int find, int left, int right)
{
while (left <= right)
{
int mid = (left + right) / 2;
if (arr[mid] == find)
return true;
else if (find > arr[mid])
left = mid + 1;
else
right = mid - 1;
}
return false;
}
int main()
{
int n, m;
cin >> n;
int have[n];
for (int i = 0; i < n; i++)
cin >> have[i];
cin >> m;
int mgive[m];
for (int i = 0; i < m; i++)
cin >> mgive[i];
sort(have, have + n);
for (int i = 0; i < m; i++)
cout << binarysearch(have, mgive[i], 0, n - 1) << ' ';
}
이런식으로 짜셈
옹 감사합담