Is it legal to use unordered_map for a pair type like <int, vector<vector<int>>>
? Visual Studio warns me "No instance of function template "std::make_pair matches the argument list" in line 16 (map.insert(make_pair<int, vector<vector<int>>>(i + m, tt))
):
void test(vector<int>& nums)
{
unordered_map<int, vector<vector<int>>> map;
unordered_map<int, unordered_set<int>> map2;
vector<vector<int>> results;
for (int i = 0; i < nums.size(); i++)
{
for (int m = i + 1; m < nums.size(); m++)
{
if (!map.count(i + m))
{
vector<int> t{ i, m };
vector<vector<int>> tt;
tt.push_back(t);
map.insert(make_pair<int, vector<vector<int>>>(i + m, tt));
map2.insert(make_pair<int, unordered_set<int>>(i + m, unordered_set<int>(i - m)));
}
else if (map2.at(i + m).count(i - m) || map2.at(i + m).count(m - i))
{
continue;
}
else
{
map.at(i + m).push_back(vector<int>{i, m});
map2.at(i + m).insert(i - m);
}
}
}
}
Aucun commentaire:
Enregistrer un commentaire