简体中文
Telegram

讨论串 消息 #1997

2 条消息 · –
  1. K
    import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Scanner; import java.util.Set; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for (int i = 0; i < t; i++) { int n = sc.nextInt(), m = sc.nextInt(); List<Set<Integer>> list = new ArrayList<>(n); loop: for (int j = 0; j < m; j++) { int a = sc.nextInt(), b = sc.nextInt(); for (Set<Integer> set: list) { if (set.contains(a)) { set.add(b); continue loop; } else if (set.contains(b)) { set.add(a); continue loop; } } Set<Integer> set = new HashSet<>(); set.add(a); set.add(b); list.add(set); } int count = 0; for (Set<Integer> set: list) { count += set.size(); } System.out.println(list.size() + n - count); } } }

来自搜索索引的公开信息流 ChatCrawler ——“公开 Telegram 的 Google”;随着该社群被抓取而更新。 时间为 UTC。

仅限公开内容,使用 Telegram 官方 API。 关于 · 常见问题 · 索引限制 · 移除页面 · 目录 · 搜索 · 计算方法