Language: C++

#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
int index[1005];
int Queue[1005][1005];
int Flag[1005];
int n, x, ans;
bool check() {
    for(int i = 1; i <= n; i++)
        if(index[i] < n)
            return true;
    return false;
}
int main() {
    cin >> n;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j < n; j++)
            cin >> Queue[i][j];
        index[i] = 1;
    }
    while(check() == true) {
        memset(Flag, 0, sizeof Flag);
        int Judge = 0;
        for(int i = 1; i <= n; i++)
            if((index[i] < n && Flag[i] == 0 && index[Queue[i][index[i]]] == n) || Queue[i][index[i]] == i) {
                cout << -1 << endl;
                return 0;
            }
            else if(index[i] < n && Flag[i] == 0 &&
                     Queue[Queue[i][index[i]]][index[Queue[i][index[i]]]] == i &&
                     Flag[Queue[i][index[i]]] == 0)
                Judge = 1, Flag[i] = Flag[Queue[i][index[i]]] = 1,  index[Queue[i][index[i]]]++, index[i]++;
        if(Judge == 0) {
            cout << -1 << endl;
            return 0;
        }
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc:6:15: error: 'int index [1005]' redeclared as different kind of entity
    6 | int index[1005];
      |               ^
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from a.cc:1:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'bool check()':
a.cc:12:17: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   12 |         if(index[i] < n)
      |                 ^
a.cc: In function 'int main()':
a.cc:21:14: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   21 |         index[i] = 1;
      |              ^
a.cc:27:22: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   27 |             if((index[i] < n && Flag[i] == 0 && index[Queue[i][index[i]]] == n) || Queue[i][index[i]] == i) {
      |                      ^
a.cc:27:69: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   27 |             if((index[i] < n && Flag[i] == 0 && index[Queue[i][index[i]]] == n) || Queue[i][index[i]] == i) {
      |                                                                     ^
a.cc:27:98: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   27 |             if((index[i] < n && Flag[i] == 0 && index[Queue[i][index[i]]] == n) || Queue[i][index[i]] == i) {
      |                                                                                                  ^
a.cc:31:26: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   31 |             else if(index[i] < n && Flag[i] == 0 &&
      |                          ^
a.cc:32:42: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   32 |                      Queue[Queue[i][index[i]]][index[Queue[i][index[i]]]] == i &&
      |                                          ^
a.cc:32:68: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   32 |                      Queue[Queue[i][index[i]]][index[Queue[i][index[i]]]] == i &&
      |                                                                    ^
a.cc:33:41: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   33 |                      Flag[Queue[i][index[i]]] == 0)
      |                                         ^
a.cc:34:57: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   34 |                 Judge = 1, Flag[i] = Flag[Queue[i][index[i]]] = 1,  index[Queue[i][index[i]]]++, index[i]++;
      |                                                         ^
a.cc:34:89: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   34 |                 Judge = 1, Flag[i] = Flag[Queue[i][index[i]]] = 1,  index[Queue[i][index[i]]]++, index[i]++;
      |                                                                                         ^
a.cc:34:103: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   34 |                 Judge = 1, Flag[i] = Flag[Queue[i][index[i]]] = 1,  index[Queue[i][index[i]]]++, index[i]++;
      |                                                                                                       ^