B. Let me sleep

Codeforces
IDCF10216B
Time3000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Hasan is lazy. He likes to stay asleep in the morning. But the dorm's supervisor always wakes him up. He will try to run from her. The dorm consists of $N$ rooms. There are $M$ portals between these rooms. To catch Hasan, the supervisor will stand at one of these portals. The supervisor can catch Hasan only if she stands in a portal between two rooms such that this portal is the only way to get between these two rooms. Hasan can add one portal between any two rooms in the dorm; if he added it optimally, what is the minimum number of portals that the supervisor can use to catch him. First line of the input will be $T$, the number of test cases. Each test case starts with a line of two numbers, $N$, $M$ ($1 <= N, M <= 10^5$)the number of rooms and portals. Next $M$ lines contain two integers, $u$ and $v$ the rooms of the $i_{t h}$ portal($1 <= u, v <= N$). For each test case, print one line, the minimum number of portals that the supervisor can use to catch him. ## Input First line of the input will be $T$, the number of test cases.Each test case starts with a line of two numbers, $N$, $M$ ($1 <= N, M <= 10^5$)the number of rooms and portals.Next $M$ lines contain two integers, $u$ and $v$ the rooms of the $i_{t h}$ portal($1 <= u, v <= N$). ## Output For each test case, print one line, the minimum number of portals that the supervisor can use to catch him. [samples]
**Definitions** Let $ G = (V, E) $ be an undirected graph with $ |V| = N $ vertices (rooms) and $ |E| = M $ edges (portals). **Constraints** 1. $ 1 \leq T \leq \text{number of test cases} $ 2. For each test case: $ 1 \leq N, M \leq 10^5 $ 3. Each edge connects two vertices $ u, v \in V $, $ u \neq v $ **Objective** The supervisor can catch Hasan only at **bridges** (edges whose removal increases the number of connected components). Hasan may add **exactly one** edge between any two vertices (possibly already connected). Find the **minimum possible number of bridges** in $ G $ after adding one edge optimally. That is, compute: $$ \min_{e' \in \binom{V}{2}} \left( \text{number of bridges in } G + \{e'\} \right) $$
API Response (JSON)
{
  "problem": {
    "name": "B. Let me sleep",
    "description": {
      "content": "Hasan is lazy. He likes to stay asleep in the morning. But the dorm's supervisor always wakes him up. He will try to run from her. The dorm consists of $N$ rooms. There are $M$ portals between these ",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 3000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10216B"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Hasan is lazy. He likes to stay asleep in the morning. But the dorm's supervisor always wakes him up. He will try to run from her.\n\nThe dorm consists of $N$ rooms. There are $M$ portals between these ...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ G = (V, E) $ be an undirected graph with $ |V| = N $ vertices (rooms) and $ |E| = M $ edges (portals).  \n\n**Constraints**  \n1. $ 1 \\leq T \\leq \\text{number of test cases} $  \n2...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments