Language: C++

#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
using namespace std;
ll binpow(ll x,ll y)/* (x^y)%p in O(log y) */{ll res=1;while (y > 0){if(y&1)res=(res*x);y = y>>1;x=(x*x);}return res;}
ll binpowmod(ll x,ll y,ll p)/* (x^y)%p in O(log y) */{ll res=1;x=x%p;while (y > 0){if(y&1)res=(res*x)%p;y = y>>1;x=(x*x)%p;}return res;}
ll mod_inverse(ll n,ll p)/* Returns n^(-1) mod p */{return binpowmod(n,p-2,p);}
ull gcd(ull x,ull y)
{
    if(y==0)
        return x;
    return gcd(y,x%y);
}
bool comp(pair<ll,ll> x,pair<ll,ll> y)
{
    return x.first>y.first;
}
bool comp_pairs_by_s(pair<ll,ll> &x ,pair<ll,ll> &y)
{
    return x.second<y.second;
}
bool isPowerOfTwo (ll x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}

class cmp      //comparator for priority_queue 
{               //declaration: priority_queue<int,vector<int>,cmp>
public:         
    bool operator()(pair<int,int> A,pair<int,int> B)
    {
        if(abs(A.first-A.second)==abs(B.first-B.second))
            return A.first>B.first;
        return abs(A.first-A.second)<abs(B.first-B.second);
    }
};
// int prime[100005]={0};
// void sieve(void)
// {
//  int i,j;
//  for(i=0;i<100005;i++)
//         prime[i]=1;
//  prime[0]=0,prime[1]=0;
//  for(i=2;i<=sqrt(100005);i++){
//      if(prime[i]){
//          for(j=i*i;j<100005;j+=i){
//              prime[j]=0;
//          }
//      }
//  }
    
// }
void swap(int &x,int &y){
    int temp=x;
    x=y;
    y=temp;
}
int played[1001][1001];
int index[1001];
int ar[1001][1001];
int cntday[1001];
void solve()
{   
    int days=0;
    int match=0;
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n-1;j++)
            cin>>ar[i][j];
    }
    for(int i=1;i<=n;i++)
        index[i]=1,cntday[i]=0;
    int curday=1;
    while(1){
        if(match==n*(n-1)/2)
            break;
        int cnt=0;
        for(int i=1;i<=n;i++){
            int j=index[i];
            if(played[i][ar[i][j]])
                continue;
            if(i==ar[ar[i][j]][index[ar[i][j]]] && cntday[i]<curday && cntday[ar[i][j]]<curday){
                played[i][ar[i][j]]=1;
                played[ar[i][j]][i]=1;
                index[i]++;
                index[ar[i][j]]++;
                match++;
                cntday[i]=curday;
                cntday[ar[i][j]]=curday; 
                cnt++;           
            }

        }
        curday++;
        // for(int i=1;i<=n;i++)
        //     cout<<i<<' '<<index[i]<<'\n';
        if(cnt==0){
            cout<<-1;
            return;
        }
    } 
    cout<<curday-1;  
    
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}


Compiler output:
a.cc:61:15: error: 'int index [1001]' redeclared as different kind of entity
   61 | int index[1001];
      |               ^
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 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 'void solve()':
a.cc:75:14: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   75 |         index[i]=1,cntday[i]=0;
      |              ^
a.cc:82:24: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   82 |             int j=index[i];
      |                        ^
a.cc:85:37: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   85 |             if(i==ar[ar[i][j]][index[ar[i][j]]] && cntday[i]<curday && cntday[ar[i][j]]<curday){
      |                                     ^
a.cc:88:22: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   88 |                 index[i]++;
      |                      ^
a.cc:89:22: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   89 |                 index[ar[i][j]]++;
      |                      ^