//其实就是判断是不是二分图,直接用染色法就好了 import java.util.*; public class Main{ static int n, m, N = 1000, M = 2 * 1000, idx; static int[] h = new int[N], e = new int[M], ne = new int[M]; static int[] color = new int[N]; static void add(int a, int b) { e[idx] = b; ne[idx] = h[a]; ...