# Untitled

unknown
plain_text
a month ago
2.1 kB
1
Indexable
Never
```import java.util.Scanner;

public class Solution {
static int n, e;
static int[] A;
static int[][] ke;
static int[][] visited;
static int result;
static int temp;

public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);

int t = sc.nextInt();

for (int tc = 1; tc <= t; tc++) {
n = sc.nextInt();
e = sc.nextInt();
int a, b;
result = 0;
temp = 0;
ke = new int[n][n];
visited = new int[n][n];

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++) {
a = sc.nextInt();
b = sc.nextInt();
ke[a][b] = 1;
ke[b][a] = 1;
}

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);
}
System.out.println(result);
}

sc.close();

}
public static 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--;
}
}
}
}

}
```