#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin >> n;
    vector<int> num(n);
    for(int i=0; i<n; i++) {
        cin >> num[i];
    }
    sort(num.begin(),num.end());
    cin >> m;
    for(int i=0 ; i<m; i++) {
        int target;
        cin >> target;
        if(binary_search(num.begin(),num.end(),target)) {
            cout << 1 << '\n';
        } else{
            cout << 0 << '\n';
        }
        
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: