Language: C++

#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

map<pair<int,int>,int> index;

class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
public:
	vector<int> in,dist;

	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
		in.resize(node_num,0);
		dist.resize(node_num,0);
	}
	void AddConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	void AddConnection2(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}

	int dfs(set<int>& visit,int from,int len){
		int new_len = len;

		for(int i=0;i<graph[from].size();i++){
			auto res = visit.emplace(graph[from][i].first);
			if(!res.second){
				//return 0;
			}
			new_len = max(new_len,dfs(visit,*res.first,len+1));
		}
		//dist[from] = new_len;
		return new_len;
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N=in();
	for(int i=0,n=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			index[make_pair(i,j)] = n++;
		}
	}

	ConnectNodeInfo connect(index.size());
	vector<vector<int>> M(N,vector<int>(N-1));
	REP(i,N){
		REP(j,N-1){
			M[i][j]=in()-1;
		}
	}
	REP(i,N){
		REP(j,N-2){
			int a=i,b=M[i][j],c=M[i][j+1];
			if(b<a) swap(a,b);
			int pre = index[make_pair(a,b)];
			a=i;
			if(c<a) swap(a,c);
			int post = index[make_pair(a,c)];
			connect.AddConnection2(pre,post,1);
			connect.in[post] = 1;
		}
	}
	
	int max_len = -1;
	REP(i,index.size()){
		if(connect.in[i]!=0) continue;
		set<int> visit;
		visit.emplace(i);
		max_len = max(max_len,connect.dfs(visit,i,1));
	}
	
	out(max_len);
	return 0;
}


Compiler output:
a.cc:25:24: error: 'std::map<std::pair<int, int>, int> index' redeclared as different kind of entity
   25 | map<pair<int,int>,int> index;
      |                        ^~~~~
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 'int main()':
a.cc:71:30: error: no match for 'operator[]' (operand types are '<unresolved overloaded function type>' and 'std::pair<int, int>')
   71 |                         index[make_pair(i,j)] = n++;
      |                              ^
a.cc:75:39: error: overloaded function with no contextual type information
   75 |         ConnectNodeInfo connect(index.size());
      |                                       ^~~~
a.cc:86:40: error: no match for 'operator[]' (operand types are '<unresolved overloaded function type>' and 'std::pair<int, int>')
   86 |                         int pre = index[make_pair(a,b)];
      |                                        ^
a.cc:89:41: error: no match for 'operator[]' (operand types are '<unresolved overloaded function type>' and 'std::pair<int, int>')
   89 |                         int post = index[make_pair(a,c)];
      |                                         ^
a.cc:96:21: error: overloaded function with no contextual type information
   96 |         REP(i,index.size()){
      |                     ^~~~
a.cc:3:35: note: in definition of macro 'REP'
    3 | #define REP(i,num) for(int i=0;i<(num);++i)
      |                                   ^~~