Open nike0good opened 5 years ago
STL in C++ is useful. By using STL, we spend less time coding and focus on other important things. For instance, by using accumulate(s.begin(),s.end()), which is used for calc the sum of a container, we can save time in writing sth. like:
ll ans=0;
for(auto p:s) ans+=p;
return p;
There are various useful algorithms:
- sort
- nth_element
- rotate(it_fir, it_mid, it_end)
- slide
- gather //means gather element with same types together
- set_difference(a.begin(),a.end(),b.begin(),b.end().back_inserter(new_items)); // return new_items (set of what is exist in $a$ and not exist in $b$ )
- stable_partition
How to make good tests?