Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<sstream>
#include<string>
#include<string.h>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#define E (2.71828182)
#define PI (3.1415926535898)
#define	mem(a,b)	memset(a,b,sizeof(a))
#define	_max(a,b,c)	(max(a,b)>c?max(a,b):c)
#define mod	1000000007
#include<set>
#define gc getchar
#define debug(a) cout << "*" << a << "*" << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<float, int> P;
const int N = 200000;
const long long  MAX_V = 5005, INF = 2147483647, MOD = 998244353;
#include <iostream>
using namespace std;
int n, a[400005], b[200005], ga[400005], gb[200005];
int next[200005];
void getNext() {
 	 int *p = gb;
     next[0] = -1;
     int j = 0;
     int k = -1;
     while (j < n - 1) {
        if (k == -1 || p[j] == p[k]) {
 		//	if (p[++j] == p[++k])
        //    next[j] = next[k];
        //    else
            next[++j] = ++k;
        } else {
            k = next[k];
        }
     }
 }
bool KMP() {
	bool f = false;
	int *t = ga, *p = gb;
	int i = 0; // 主串的位置
	int j = 0; // 模式串的位置
	while (i < 2 * n - 1) {
		if (j == -1 || t[i] == p[j]) { // 当j为-1时，要移动的是i，当然j也要归0
            i++;
            j++;
        	if (j == n)
        	{
        		f = true;
        		printf("%d %d\n", i - j, b[0] ^ a[i - j]);
        		j = next[j - 1] + 1;
			}
        } else {
            // i不需要回溯了
            // i = i - j + 1;
            j = next[j]; // j回到指定位置
 
        }
 
     }
     return f;
}
int main()
{
	while (~scanf("%d", &n))
	{
		for (int i = 0; i < n; i++)	
		{
			scanf("%d", &a[i]);
			if (i)
				ga[i - 1] = a[i - 1] ^ a[i]; 
		}
		ga[n - 1] = a[n - 1] ^ a[0];
		for (int i = 0; i < n; i++)	
		{
			scanf("%d", &b[i]);
			if (i)
				gb[i - 1] = b[i - 1] ^ b[i]; 
		}
		gb[n - 1] = b[n - 1] ^ b[0];
		for (int i = n; i < 2 * n; i++)	ga[i] = ga[i - n];
		getNext();
		if(!KMP())	printf("\n");
	}
}


Compiler output:
a.cc: In function 'void getNext()':
a.cc:32:6: error: reference to 'next' is ambiguous
   32 |      next[0] = -1;
      |      ^~~~
In file included from /usr/include/c++/14/string:47,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:29:5: note:                 'int next [200005]'
   29 | int next[200005];
      |     ^~~~
a.cc:40:13: error: reference to 'next' is ambiguous
   40 |             next[++j] = ++k;
      |             ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:29:5: note:                 'int next [200005]'
   29 | int next[200005];
      |     ^~~~
a.cc:42:17: error: reference to 'next' is ambiguous
   42 |             k = next[k];
      |                 ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:29:5: note:                 'int next [200005]'
   29 | int next[200005];
      |     ^~~~
a.cc: In function 'bool KMP()':
a.cc:59:29: error: reference to 'next' is ambiguous
   59 |                         j = next[j - 1] + 1;
      |                             ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:29:5: note:                 'int next [200005]'
   29 | int next[200005];
      |     ^~~~
a.cc:64:17: error: reference to 'next' is ambiguous
   64 |             j = next[j]; // j回到指定位置
      |                 ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:29:5: note:                 'int next [200005]'
   29 | int next[200005];
      |     ^~~~