import java.util.*; /** *奶牛 **/ public class Main2 { public static void main(String[] args) { Scanner scanner=new Scanner(System.in); int T = scanner.nextInt(); while (T> 0) { int n=scanner.nextInt(); int m=scanner.nextInt(); Map<Integer,Integer> map=new HashMap<>(); for (int i = 0; i < m; i++) { int m1=scanner.nextInt(); for (int j = 0; j < m1; j++) { int l1=scanner.nextInt(); int l2=scanner.nextInt(); for (int k = l1; k <=l2 ; k++) { map.put(k,map.getOrDefault(k,0)+1); } } } List<Integer> list=new ArrayList<>(); for (Map.Entry<Integer, Integer> entry : map.entrySet()) { Integer key = entry.getKey(); Integer value = entry.getValue(); if (value == m) { list.add(key); } } Collections.sort(list); System.out.println(list.size()); for (int i = 0; i < list.size(); i++) { System.out.print(list.get(i)+" "); } T--; } } }
全部评论
(6) 回帖