### Problem
A binary isInfected grid has infected cells marked 1 and susceptible cells marked 0. Infection spreads nightly to side-adjacent susceptible cells unless a wall blocks their shared boundary. Each day quarantine the one connected infected region threatening the largest number of distinct susceptible cells; that choice has no tie. Install all boundary walls needed to contain it, then let every other active region spread one step simultaneously. Return the total walls built until no further spread is possible, including when the world becomes fully infected.
```cpp
class Solution {
public:
int containVirus(vector<vector<int>>& isInfected);
};
```
### Examples
**Example 1:**
```text
isInfected = [[1,0,0]]
Output: 1
Explanation: One boundary wall contains the only region.
```
**Example 2:**
```text
isInfected = [[1,1],[1,0]]
Output: 2
Explanation: The susceptible corner touches the region on two distinct sides, requiring two walls.
```
### Constraints
- The grid is rectangular, with both dimensions in [1,50].
- Initial cells contain only 0 or 1.
- Whenever a spreading-region choice is needed, one region threatens strictly more susceptible cells than every other region.
### Contract considerations
Follow the source's unique-largest-region policy; this is simulation, not a search over alternative quarantine strategies.
```hint Read the boundary condition
Why can one threatened cell require more than one wall?
```
### Boundary reminders
Follow the source's unique-largest-region policy; this is simulation, not a search over alternative quarantine strategies.
Overview: Quarantine the Region Threatening the Most Cells. A binary isInfected grid has infected cells marked 1 and susceptible cells marked 0.
A binary isInfected grid has infected cells marked 1 and susceptible cells marked 0. Infection spreads nightly to side-adjacent susceptible cells unless a wall blocks their shared boundary. Each day quarantine the one connected infected region threatening the largest number of distinct susceptible cells; that choice has no tie. Install all boundary walls needed to contain it, then let every other active region spread one step simultaneously. Return the total walls built until no further spread is possible, including when the world becomes fully infected.
class Solution {
public:
int containVirus(vector<vector<int>>& isInfected);
};
Examples
Example 1:
isInfected = [[1,0,0]]
Output: 1
Explanation: One boundary wall contains the only region.
Example 2:
isInfected = [[1,1],[1,0]]
Output: 2
Explanation: The susceptible corner touches the region on two distinct sides, requiring two walls.
Constraints
The grid is rectangular, with both dimensions in [1,50].
Initial cells contain only 0 or 1.
Whenever a spreading-region choice is needed, one region threatens strictly more susceptible cells than every other region.
Contract considerations
Follow the source's unique-largest-region policy; this is simulation, not a search over alternative quarantine strategies.
Boundary reminders
Follow the source's unique-largest-region policy; this is simulation, not a search over alternative quarantine strategies.