//0 1 2 3 4五个队伍 10场比赛的双方 private static int[] a = {0, 0, 0, 0, 1, 1, 1, 2, 2, 3}; private static int[] b = {1, 2, 3, 4, 2, 3, 4, 3, 4, 4}; private static Integer[] scores = new Integer[5]; private static Set<List<Integer>> set = new HashSet<>(); public static void main(String[] args) { Arrays.fill(scores, 0); dfs(0); } public static void dfs(int depth) { if (depth == 10) { Integer[] copyScores = Arrays.copyOf(scores, scores.length); Arrays.sort(copyScores); List<Integer> copyScoresList = Arrays.asList(copyScores); set.add(copyScoresList); return; } scores[a[depth]] += 3; dfs(depth+1); scores[a[depth]] -= 3; scores[b[depth]] += 3; dfs(depth+1); scores[b[depth]] -= 3; scores[a[depth]] += 1; scores[b[depth]] += 1; dfs(depth+1); scores[a[depth]] -= 1; scores[b[depth]] -= 1; }