CP Shots
upper_bound in C++
upper_bound() is a standard library function in C++ defined in the header. It returns an iterator pointing to the first element in the range [first, last] that is greater than value, or last if no such element is found. The elements in the range shall already be sorted or at least partitioned with respect to val. Classic example - https://codeforces.com/problemset/problem/706/B
Find a value in a vector.
Get substring from a string
Find a substring inside a string
β Fast I/O in CPP
Add below lines after your int main()
line :
Set precision according to question constraints
Add below lines after int main()
line :
Pointers
Try using const in modulo operations, since Modulo operations are very fast with constant mod (because compiler notices constant, and so instead of actually dividing, replaces it with a sequence of faster bitwise operations) A trivial example would be % 2 being replaced by ^ 1.
Bitwise : https://codeforces.com/blog/entry/72437
memset
function is forchar
or1 byte
data types only. Somemset(a, 1, sizeof(a))
won't work π₯·https://www.geeksforgeeks.org/memset-in-cpp/Use
\n
overendl
: https://www.geeksforgeeks.org/endl-vs-n-in-cpp/
Last updated