import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int testN = Integer.parseInt(in.nextLine());
// in.nextLine();
// while (in.hasNextLine()) {
for (int a = 0; a < testN; a++) {
String[] nmArr = in.nextLine().split(" ");
int n = Integer.parseInt(nmArr[0]), m = Integer.parseInt(nmArr[1]);
int[] flags = new int[n + 1];
for (int i = 0; i < m; i++) {
int propsNum = Integer.parseInt(in.nextLine());
for (int j = 0; j < propsNum; j++) {
String[] arr = in.nextLine().split(" ");
int left = Integer.parseInt(arr[0]), right = Integer.parseInt(arr[1]);
for (int k = left; k <= right; k++) {
flags[k]++;
}
}
}
List<Integer> result = new ArrayList<>(100);
for (int i = 1; i <= n; i++) {
if (flags[i] == m) {
result.add(i);
}
}
System.out.println(result.size());
for (Integer integer : result) {
System.out.print(integer + " ");
}
}
}
}
代码报超时,什么问题呀。。本地没问题
全部评论
(0) 回帖