Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
818 B
3
Indexable
Never
#include <bits/stdc++.h>
    
using namespace std;
 
bool check(string a, string b) {
    string tmp = "";
    int i = 0, j = 0;
    while (i < a.length() and j < b.length()) {
        if (a[i] == b[j]) {
            tmp += a[i];
            ++i;
            ++j;
        } else {
            ++i;
        }
    }
    if (tmp == b)
        return true;
    else
        return false;
}
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    int n;
    string a;
 
    cin >> n >> a;
 
    int m;
    cin >> m;
    vector<string> others(m);
    for (int i = 0; i < m; ++i) {
        int len;
        cin >> len >> others[i];
    }
    string out = "";
    for (int i = 0; i < m; ++i) {
        if (check(a, others[i]))
            out += "0";
        else
            out += "1";
    }
    cout << out;
}