B. Buffoon

Codeforces
IDCF10234B
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
The complete problemset is available on http://maratona.ime.usp.br/primfase19/provas/competicao/maratona_en.pdf [samples]
**Definitions** Let $ T = (V, E) $ be a tree with $ |V| = n $, $ V = \{1, 2, \dots, n\} $. Let $ C \subseteq V $, $ |C| = k $, be the set of colored vertices, with $ C = \{a_1, a_2, \dots, a_k\} $. Let $ U = V \setminus C $ be the set of uncolored vertices. For a vertex $ x \in U $, let $ T_x $ denote the tree rooted at $ x $. Let $ \text{children}(x) $ be the set of children of $ x $ in $ T_x $. For each child $ c \in \text{children}(x) $, let $ T_c $ be the subtree rooted at $ c $. **Constraints** 1. $ 2 \le n \le 2 \cdot 10^5 $ 2. $ 1 \le k < n $ 3. $ C \subset V $, all $ a_i \in V $ are distinct 4. $ T $ is connected and acyclic **Objective** A vertex $ x \in U $ is *interesting* if, for every child $ c \in \text{children}(x) $, the subtree $ T_c $ contains at least one vertex from $ C $. Find the set $ I = \{ x \in U \mid x \text{ is interesting} \} $, and output $ |I| $ and the elements of $ I $ in ascending order.
API Response (JSON)
{
  "problem": {
    "name": "B. Buffoon",
    "description": {
      "content": "The complete problemset is available on http://maratona.ime.usp.br/primfase19/provas/competicao/maratona_en.pdf ",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10234B"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "The complete problemset is available on http://maratona.ime.usp.br/primfase19/provas/competicao/maratona_en.pdf\n\n[samples]...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ T = (V, E) $ be a tree with $ |V| = n $, $ V = \\{1, 2, \\dots, n\\} $.  \nLet $ C \\subseteq V $, $ |C| = k $, be the set of colored vertices, with $ C = \\{a_1, a_2, \\dots, a_k\\} $...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments