I get The idea of Problem D Today But I was getting WA and I did not know where is the wrong.. After the contest I discovered that my map donot do sorting to vector of string in it ...
why ???
map<char, vector<string>>mp;
for(auto i:mp){
sort(i.second.begin(), i.second.end());
}
this is the test that my friend give me after contest:
1
1
D
9H 4H
you should have done sort(mp[i.first].begin(), mp[i.first].end());
ACCEPTED but Why ??
because u are sorting a copy without replacing it back to the map
thanks
sorting the vector, $$$mp[i.first]$$$, rather than its copy, $$$i$$$
Auto comment: topic has been updated by mostafaabdelaal_03 (previous revision, new revision, compare).
for (auto &i : mp), you just make a copy every time
Yes it's the reference trick.
Or you can use iterators:
for (auto it=mp.begin();it!=mp.end();it++) sort(it->second.begin(),it->second.end());
I think using maps is overcomplicating