Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
1.1 kB
2
Indexable
Never
#include<iostream>
using namespace std;
int n, e, A[50];
int ke[50][50];
int visited[50][50];
int top;
int end1;
int queue[100];
int queue2[100];
int result;
int temp;
void catan(int x){
	for(int i=0; i<n; i++){
		if(visited[x][i]==0 && visited[i][x]==0){

			if(ke[x][i]==1){
				temp++;
				if(temp>result) result=temp;
				visited[x][i]=1;
				visited[i][x] = 1;
				catan(i);
				visited[x][i]=0;
				visited[i][x] = 0;
				temp--;
			}
		}
	}
}
int main(){
	//freopen("in.txt", "r", stdin);
	int t;
	cin>>t;

	for(int tc=1; tc<=t; tc++){
		cin>>n>>e;
		int a,b;
		result=0;
		temp=0;
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				ke[i][j]=0;
				ke[j][i]=0;
				visited[i][j]=0;
				visited[j][i] = 0;
			}
		}
		for(int i=1; i<=e; i++){
			cin>>a>>b;
			ke[a][b] = 1;
			ke[b][a] = 1;
		}
		int maxx = 0;
		for(int i=0; i<n; i++){
			for(int f=0; f<n; f++)
				for(int j=0; j<n; j++){
					visited[j][f] = 0;
					visited[f][j] = 0;
				}
			catan(i);
		}
		cout<<result<<endl;
	}
	return 0;
}