func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6 + 111;   int a[maxn];   int getid[maxn];   int b[maxn];   int lpos[maxn];   vector<int> savepos[maxn];   vector<int> G[maxn];   vector<int> v;   int n, m, q;   int vis[maxn];   void dfs(int pos, int fa) {     v.push_back(pos);     vis[pos] = 1;     if (v.size() >= n) {       int id = v.size() - n;       lpos[pos] = v[id];     }     for (int d : G[pos]) {       if (d == fa) continue;       dfs(d, pos);     }     v.pop_back();   }   int main() {     cin >> n >> m >> q;     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       getid[a[i]] = i;     }     for (int i = 1; i <= m; i++) {       scanf( %d , &b[i]);       savepos[b[i]].push_back(i);     }     for (int i = 1; i <= m; i++) {       int nowval = b[i];       int preid = getid[nowval] - 1;       if (!preid) preid = n;       int preval = a[preid];       int id = lower_bound(savepos[preval].begin(), savepos[preval].end(), i) -                savepos[preval].begin() - 1;       if (id >= 0) {         G[savepos[preval][id]].push_back(i);       }       savepos[nowval].push_back(i);     }     for (int i = 1; i <= m; i++) {       if (!vis[i]) {         v.clear();         dfs(i, -1);       }     }     int p = 0;     for (int i = 1; i <= m; i++) {       lpos[i] = max(lpos[i - 1], lpos[i]);     }     while (q--) {       int l, r;       scanf( %d %d , &l, &r);       if (l <= lpos[r]) {         cout << 1;       } else {         cout << 0;       }     }   }   