Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
const int INF=1000000000;

int main(){
    int N;cin>>N;
    vector<int> info(N,INF);
    rep(i,N){
        rep(j,N){
          	char x;
      	    cin >> x;
            if (i==j){
                info[i][j]=0;
            }
            if (x=='1'){
            	info[i][j]=1;
            }
        }
    }
    vector<int> a[N];
    rep(i,N){
        rep(j,N){
            if(info[i][j])a[i].push_back(j);
        }
    }

    //二部グラフ判定
    int color[N];
    rep(i,N)color[i]=-1;
    color[0]=0;
    bool ok=true;
    rep(i,N){
        for(int j=0;j<a[i].size();j++){
            if(color[a[i][j]]==color[i]){
                ok=false;
                i=N;
                j=a[i].size();
            }
            else color[a[i][j]]=!color[i];
        }
    }


    if(ok==false)cout<<-1<<endl;
    else{ //warshall_floyd
        rep(k,N){
            rep(i,N){
                rep(j,N){
                    if(info[i][k]==INF||info[k][j]==INF)continue;
                    info[i][j]=min(info[i][j],info[i][k]+info[k][j]);
                }
            }
        }
        int ans=0;
        rep(i,N){
            rep(j,N){
                ans=max(ans,info[i][j]);
            }
        }
        cout<<ans+1<<endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:24: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   15 |                 info[i][j]=0;
      |                        ^
a.cc:18:24: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   18 |                 info[i][j]=1;
      |                        ^
a.cc:25:23: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   25 |             if(info[i][j])a[i].push_back(j);
      |                       ^
a.cc:51:31: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   51 |                     if(info[i][k]==INF||info[k][j]==INF)continue;
      |                               ^
a.cc:51:48: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   51 |                     if(info[i][k]==INF||info[k][j]==INF)continue;
      |                                                ^
a.cc:52:28: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   52 |                     info[i][j]=min(info[i][j],info[i][k]+info[k][j]);
      |                            ^
a.cc:52:43: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   52 |                     info[i][j]=min(info[i][j],info[i][k]+info[k][j]);
      |                                           ^
a.cc:52:54: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   52 |                     info[i][j]=min(info[i][j],info[i][k]+info[k][j]);
      |                                                      ^
a.cc:52:65: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   52 |                     info[i][j]=min(info[i][j],info[i][k]+info[k][j]);
      |                                                                 ^
a.cc:59:36: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   59 |                 ans=max(ans,info[i][j]);
      |                                    ^