Language: C++

#include<cstdio>
#include<string>
#include<algorithm>

#define MAX 1000002

int Lv[MAX], A[MAX], newLv[MAX];
int n, k;
string T;

bool cmp_Lv(const int i, const int j){ return Lv[i] < Lv[j]; }

bool cmp(const int i, const int j){
	if(Lv[i] != Lv[j]){ return Lv[i] < Lv[j]; }
	int L_i = (i + k >= n ? -1 : Lv[i + k]);
	int L_j = (j + k >= n ? -1 : Lv[j + k]);

	return L_i < L_j;
}

int main()
{
	std::cin >> T;
	n = T.size();

	int i;
	for(i = 0; i < n; i++){ A[i] = i; }
	for(i = 0; i < n; i++){ Lv[i] = T[i]; }
	sort(A, A + n, cmp_Lv);

	newLv[A[0]] = 0;
	for(i = 1; i < n; i++){
		newLv[A[i]] = newLv[A[i - 1]] + (Lv[A[i]] != Lv[A[i - 1]] ? 1 : 0);
	}
	for(i = 0; i < n; i++){ Lv[i] = newLv[i]; }

	k = 1;
	while(1){
		if(k > n) break;

		sort(A, A + n, cmp);
		newLv[A[0]] = 0;
		for(i = 1; i < n; i++){ newLv[A[i]] = newLv[A[i - 1]] + (cmp(A[i - 1], A[i]) ? 1 : 0); }
		for(i = 0; i < n; i++){ Lv[i] = newLv[i]; }

		if(Lv[A[n - 1]] == n - 1) break;
		k <<= 1;
	};

	string P;
	int q, left, right, mid, crit;
	bool exist;
	scanf("%d", &q);

	A[n] = n;

	while(q){
		std::cin >> P;
		left = 0, right = n, exist = false;
		while(left < right){

			if(n < P.size()){ exist = false; break; }

			mid = (left + right) / 2;
			crit = T.compare(A[mid], P.size(), P);

			if(crit > 0){ right = mid; }
			else if(crit < 0){ left = mid + 1; }
			else{ exist = true; break; }
		};
		if(T.compare(A[right], P.size(), P) == 0) exist = true;
		if(exist){ printf("1\n"); }else{ printf("0\n"); }
		q--;
	}
	return 0;
}

Compiler output:
a.cc:9:1: error: 'string' does not name a type; did you mean 'stdin'?
    9 | string T;
      | ^~~~~~
      | stdin
a.cc: In function 'int main()':
a.cc:23:14: error: 'cin' is not a member of 'std'
   23 |         std::cin >> T;
      |              ^~~
a.cc:4:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    3 | #include<algorithm>
  +++ |+#include <iostream>
    4 | 
a.cc:23:21: error: 'T' was not declared in this scope
   23 |         std::cin >> T;
      |                     ^
a.cc:29:9: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   29 |         sort(A, A + n, cmp_Lv);
      |         ^~~~
      |         std::sort
In file included from /usr/include/c++/14/algorithm:86,
                 from a.cc:3:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
a.cc:50:9: error: 'string' was not declared in this scope
   50 |         string P;
      |         ^~~~~~
a.cc:50:9: note: suggested alternatives:
In file included from /usr/include/c++/14/string:41,
                 from a.cc:2:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:58:22: error: 'cin' is not a member of 'std'
   58 |                 std::cin >> P;
      |                      ^~~
a.cc:58:22: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:58:29: error: 'P' was not declared in this scope
   58 |                 std::cin >> P;
      |                             ^