Just a runnable solution
Code\n\nstruct MySolution {\n    infected: Vec<Vec<i32>>,\n    n: usize,\n    m: usize,\n    c: i32,\n    mx: usize,\n    w: i32,\n    r: i32,\n    ans: i32,\n 
# Code\n```\nstruct MySolution {\n    infected: Vec<Vec<i32>>,\n    n: usize,\n    m: usize,\n    c: i32,\n    mx: usize,\n    w: i32,\n    r: i32,\n    ans: i32,\n    itr: i32,\n    s: std::collections::HashSet<usize>,\n}\n\nimpl MySolution {\n    fn new() -> Self {\n        MySolution {\n            infected: vec![vec![]],\n            n: 0,\n            m: 0,\n            c: 2,\n            mx: 0,\n            w: 0,\n            r: 0,\n            ans: 0,\n            itr: 0,\n            s: std::collections::HashSet::new(),\n        }\n    }\n\n    fn dfs(&mut self, i: i32, j: i32) -> i32 {\n        if i < 0 || j < 0 {\n            return 0;\n        }\n        let (i, j) = (i as usize, j as usize);\n        if i >= self.n || j >= self.m || self.infected[i][j] != 1 {\n            return 0;\n        }\n        let mut ans = 0;\n        if i + 1 < self.n && self.infected[i + 1][j] == 0 {\n            self.s.insert((i + 1) * self.m + j);\n            ans += 1;\n        }\n        if i >= 1 && self.infected[i - 1][j] == 0 {\n            self.s.insert((i - 1) * self.m + j);\n            ans += 1;\n        }\n        if j + 1 < self.m && self.infected[i][j + 1] == 0 {\n            self.s.insert(i * self.m + (j + 1));\n            ans += 1;\n        }\n        if j >= 1 && self.infected[i][j - 1] == 0 {\n            self.s.insert(i * self.m + (j - 1));\n            ans += 1;\n        }\n        self.infected[i][j] = self.c;\n        ans += self.dfs(i as i32 + 1, j as i32);\n        ans += self.dfs(i as i32 - 1, j as i32);\n        ans += self.dfs(i as i32, j as i32 + 1);\n        ans += self.dfs(i as i32, j as i32 - 1);\n        ans\n    }\n\n    fn contain_virus(&mut self, infected: Vec<Vec<i32>>) -> i32 {\n        self.infected = infected;\n        self.n = self.infected.len();\n        self.m = self.infected[0].len();\n        self.ans = 0;\n        loop {\n            self.c = 2;\n            self.mx = 0;\n            for i in 0..self.n {\n                for j in 0..self.m {\n                    if self.infected[i][j] == 1 {\n                        self.s.clear();\n                        let walls = self.dfs(i as i32, j as i32);\n                        if self.mx < self.s.len() {\n                            self.mx = self.s.len();\n                            self.w = walls;\n                            self.r = self.c;\n                        }\n                        self.c += 1;\n                    }\n                }\n            }\n            if self.mx == 0 {\n                break;\n            }\n            self.ans += self.w;\n            for i in 0..self.n {\n                for j in 0..self.m {\n                    if self.infected[i][j] == self.r {\n                        self.infected[i][j] = 1e9 as i32;\n                    } else if self.infected[i][j] > 1 && self.infected[i][j] != 1e9 as i32 {\n                        self.infected[i][j] = 1;\n                        if i + 1 < self.n && self.infected[i + 1][j] == 0 {\n                            self.infected[i + 1][j] = 1;\n                        }\n                        if i >= 1 && self.infected[i - 1][j] == 0 {\n                            self.infected[i - 1][j] = 1;\n                        }\n                        if j + 1 < self.m && self.infected[i][j + 1] == 0 {\n                            self.infected[i][j + 1] = 1;\n                        }\n                        if j >= 1 && self.infected[i][j - 1] == 0 {\n                            self.infected[i][j - 1] = 1;\n                        }\n                    }\n                }\n            }\n        }\n        self.ans\n    }\n}\n\nimpl Solution {\n    pub fn contain_virus(is_infected: Vec<Vec<i32>>) -> i32 {\n        let mut my_solution = MySolution::new();\n        my_solution.contain_virus(is_infected)\n    }\n}\n```
['Rust']