BFS (or DFS)
We can represent bombs using a directed graph - when a bomb i can detonate bomb j, there is an edge from i to j. Note that the opposite may not be true.\n\nWe g
We can represent bombs using a *directed* graph - when a bomb `i` can detonate bomb `j`, there is an edge from `i` to `j`. Note that the opposite may not be true.\n\nWe generate this graph (`al`), and, starting from each node, we run BFS (or DFS) and find out how many nodes we can reach.\n\n#### DFS\nUsing a bitset boosted the runtime to 28 ms.\n\n**C++**\n```cpp\nint dfs(int i, vector<vector<int>> &al, bitset<100> &detonated) {\n    if (!detonated[i]) {\n        detonated[i] = true;\n        for (int j : al[i])\n            dfs(j, al, detonated);\n    }\n    return detonated.count();\n}\nint maximumDetonation(vector<vector<int>>& bs) {\n    int res = 0, sz = bs.size();\n    vector<vector<int>> al(bs.size());\n    for (int i = 0; i < sz; ++i) {\n        long long x = bs[i][0], y = bs[i][1], r2 = (long long)bs[i][2] * bs[i][2];\n        for (int j = 0; j < bs.size(); ++j)\n            if ((x - bs[j][0]) * (x - bs[j][0]) + (y - bs[j][1]) * (y - bs[j][1]) <= r2)\n                al[i].push_back(j);\n    }\n    for (int i = 0; i < sz && res < sz; ++i)\n        res = max(dfs(i, al, bitset<100>() = {}), res);\n    return res;\n}\n```\n\n#### BFS\n**C++**\n```cpp\nint maximumDetonation(vector<vector<int>>& bs) {\n    int res = 0, sz = bs.size();\n    vector<vector<int>> al(bs.size());\n    for (int i = 0; i < sz; ++i) {\n        long long x = bs[i][0], y = bs[i][1], r2 = (long long)bs[i][2] * bs[i][2];\n        for (int j = 0; j < bs.size(); ++j)\n            if ((x - bs[j][0]) * (x - bs[j][0]) + (y - bs[j][1]) * (y - bs[j][1]) <= r2)\n                al[i].push_back(j);\n    }\n    for (int i = 0; i < sz && res < sz; ++i) {\n        vector<int> q{i};\n        unordered_set<int> detonated{i};\n        while (!q.empty()) {\n            vector<int> q1;\n            for (int j : q)\n                for (int k : al[j])\n                    if (detonated.insert(k).second)\n                        q1.push_back(k);\n            swap(q, q1);\n        }\n        res = max((int)detonated.size(), res);\n    }\n    return res;\n}\n```
[]