Language: C++

#include<queue>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
using namespace std;

typedef long long ll;
int a[10005][10005];
int index[1005];
bool vis[1005];

int main()
{
    ll n;
    cin>>n;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n-1;j++)
            cin>>a[i][j];
    for(int i=1;i<=n;i++)
        index[i]=1;
    int ans=0;
    while(true)
    {
        for(int i=1;i<=n;i++)
            vis[i]=false;
        for(int i=1;i<=n;i++)
        {
            if(index[i]!=n&&index[a[i][index[i]]]!=n&&vis[i]==false&&vis[a[i][index[i]]]==false&&a[a[i][index[i]]][index[a[i][index[i]]]]==i)
            {
                vis[i]=true;
                vis[a[i][index[i]]]=true;
                index[a[i][index[i]]]++,index[i]++;
            }

        }
        bool flag=true;
        for(int j=1;j<=n;j++)
            if(vis[j]==true)
        {
            flag=false;
            break;
        }
        if(flag)
            break;
        ans++;
    }
    bool flag=true;
    for(int i=1;i<=n;i++)
        if(index[i]!=n)
    {
        flag=false;
        break;
    }
    if(flag)
        cout<<ans<<endl;
    else
        cout<<"-1"<<endl;

    return 0;
}
///*
//
//4 6 0
//0 1 2
//1 2 2
//1 3 1
//0 2 5
//1 3 3
//0 3 4
//
//
//
//*/


Compiler output:
a.cc:11:15: error: 'int index [1005]' redeclared as different kind of entity
   11 | int index[1005];
      |               ^
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from a.cc:5:
/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 'int main()':
a.cc:22:14: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   22 |         index[i]=1;
      |              ^
a.cc:30:21: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   30 |             if(index[i]!=n&&index[a[i][index[i]]]!=n&&vis[i]==false&&vis[a[i][index[i]]]==false&&a[a[i][index[i]]][index[a[i][index[i]]]]==i)
      |                     ^
a.cc:30:45: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   30 |             if(index[i]!=n&&index[a[i][index[i]]]!=n&&vis[i]==false&&vis[a[i][index[i]]]==false&&a[a[i][index[i]]][index[a[i][index[i]]]]==i)
      |                                             ^
a.cc:30:84: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   30 |             if(index[i]!=n&&index[a[i][index[i]]]!=n&&vis[i]==false&&vis[a[i][index[i]]]==false&&a[a[i][index[i]]][index[a[i][index[i]]]]==i)
      |                                                                                    ^
a.cc:30:110: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   30 |             if(index[i]!=n&&index[a[i][index[i]]]!=n&&vis[i]==false&&vis[a[i][index[i]]]==false&&a[a[i][index[i]]][index[a[i][index[i]]]]==i)
      |                                                                                                              ^
a.cc:30:132: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   30 |             if(index[i]!=n&&index[a[i][index[i]]]!=n&&vis[i]==false&&vis[a[i][index[i]]]==false&&a[a[i][index[i]]][index[a[i][index[i]]]]==i)
      |                                                                                                                                    ^
a.cc:33:31: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   33 |                 vis[a[i][index[i]]]=true;
      |                               ^
a.cc:34:33: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   34 |                 index[a[i][index[i]]]++,index[i]++;
      |                                 ^
a.cc:34:46: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   34 |                 index[a[i][index[i]]]++,index[i]++;
      |                                              ^
a.cc:51:17: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   51 |         if(index[i]!=n)
      |                 ^