C++ Solution
Code\ncpp []\nclass Solution {\npublic:\n    bool valid(const string& s) {\n        if (s.empty()) return false;\n        if (s == "0") return true;\n        if
# Code\n```cpp []\nclass Solution {\npublic:\n    bool valid(const string& s) {\n        if (s.empty()) return false;\n        if (s == "0") return true;\n        if (s[0] == \'0\') return false;\n        return true;\n    }\n    bool validDecimal(const string& s) {\n        bool flag = true;\n        for (char c : s) if (c == \'.\') flag = false;\n        if (flag) return valid(s);\n        if (s.empty()) return false;\n        if (s.back() == \'.\' || s.back() == \'0\' || s[0] == \'.\') return false;\n        if (s[0] == \'0\' && s[1] != \'.\') return false;\n        return true;\n    }\n    void update(const string& a, const string& b, unordered_set<string>& uset) {\n        unordered_set<string> A, B;\n        if (valid(a)) A.insert(a);\n        if (valid(b)) B.insert(b);\n        for (int i = 0; i <= a.size(); i++) {\n            string temp = a;\n            temp.insert(temp.begin() + i, \'.\');\n            if (validDecimal(temp)) A.insert(temp);\n        }\n        for (int i = 0; i <= b.size(); i++) {\n            string temp = b;\n            temp.insert(temp.begin() + i, \'.\');\n            if (validDecimal(temp)) B.insert(temp);\n        }\n        for (string aa : A) for (const string pref = "(" + aa + ", "; string bb : B) uset.insert(pref + bb + ")");\n    }\n    vector<string> ambiguousCoordinates(const string& s) {\n        string a = s.substr(1);\n        a.pop_back();\n        string b;\n        for (char c : a) if (c != \' \' && c != \'.\') b += c;\n        unordered_set<string> ret;\n        for (int i = 0; i < size(b); i++) {\n            const string A = string(b.begin(), b.begin() + i);\n            const string B = string(b.begin() + i, b.end());\n            update(A, B, ret);\n        }\n        return vector<string>(ret.begin(), ret.end());\n    }\n};\n```
['C++']