- https://codeforces.com/blog/entry/57282
- https://www.geeksforgeeks.org/how-to-prepare-for-acm-icpc/
- https://blog.shahjalalshohag.com/topic-list/
C++ does not allow to return an entire array as an argument to a function. However, you can return a pointer to an array by specifying the array's name without an index. https://www.tutorialspoint.com/cplusplus/cpp_return_arrays_from_functions.htm
Adds a new element at the end of the vector, after its current last element. The content of val is copied (or moved) to the new element.
This effectively increases the container size by one, which causes an automatic reallocation of the allocated storage space if -and only if- the new vector size surpasses the current vector capacity.
g++ foo.cpp
if you want to specify filename
g++ -o output foo.cpp
mac m1 clang++ foo.cpp
If you're going to use streams, you can also use ostream_iterator
in conjunction with a looping construct like copy
:
vector<string> data;
data.assign(10, "hello");
copy( &data[0], &data[3], ostream_iterator<string>(cout, " "));
Note that the second parameter to copy
points to one past the end.
The choice of which set implementation to use is often a matter of taste. The benefit of the set structure is that it maintains the order of the elements and provides functions that are not available in unordered_set . On the other hand, unordered_set can be more efficient.
https://stackoverflow.com/questions/152555/h-or-hpp-for-your-class-definitions
scanf("%[^\n]%*c", s);
- %d integer
- %p pointer location
- %x hex
- %c character
- %s string
- %lf float
- %f float
- %.1f float 1 angka di belakang koma
g++ -o main -I/source/includes main.cpp
https://stackoverflow.com/questions/15891781/how-to-call-on-a-function-found-on-another-file
http://www.cplusplus.com/forum/beginner/111502/
You can go back to the last buffer using :b# https://stackoverflow.com/questions/9160499/go-to-back-directory-browsing-after-opening-file-in-vim
https://www.youtube.com/watch?v=Z_hPJ_EhceI
- std::map<X, Y>:
is an ordered structure with respect to keys (that is, when you iterate over it, keys will be always increasing). supports unique keys (Xs) only offers fast find() method (O(log n)) which finds the Key-Value pair by Key offers an indexing operator map[key], which is also fast
- std::list<std::pair<X, Y> >:
is a simple sequence of paired Xs and Ys. They remain in the order you put it in. can hold any number of duplicates finding a particular key in a list is O(N) (no special method) offers the splice method.
https://github.com/Optixal/neovim-init.vim
- ctrl + w + w
Activate the NERDTree and navigate to the directory in which the new file should live. Then press m to bring up the NERDTree Filesystem Menu and choose a for "add child node". Then simply enter the file's (or directory's name) and you're done.
- To find a word in Vi/Vim, simply type the / or ? key, followed by the word you're searching for.
- Once found, you can press the n key to go directly to the next occurrence of the word.
- Vi/Vim also allows you to launch a search on the word over which your cursor is positioned. To do this, place the cursor over the term, and then press * or # to look it up.
https://vi.stackexchange.com/questions/514/how-do-i-change-the-current-splits-width-and-height
, - Map leader, nearly all my custom mappings starts with pressing the comma key
,q or \\ - Toggle sidebar filetree viewer (nvim-tree.lua)
,r - Refresh/source ~/.config/nvim/init.vim
,t - Trim all trailing whitespaces
,a - Auto align variables (vim-easy-align), eg. do ,a= while your cursor is on a bunch of variables to align their equal signs
,h - Toggle rainbow parentheses highlighting (rainbow-parentheses.vim)
,j - Set filetype to "journal" which makes the syntax highlighting beautiful when working on regular text files and markdown
,k - Toggle coloring of hex colors
,l - Toggle Limelight mode, highlight the lines near cursor only (Limelight)
,, - Remove highlights (after searching with /)
<Tab> - Next buffer
<Shift-Tab> - Previous buffer
,$s - New terminal in horizontal split
,$v - New terminal in vertical split
,ff - Find files ,fg - Live grep from files ,fb - Buffers ,fh - Help tags ,fc - Change colorscheme ,f/ - Fuzzy find current buffer
d
to delete a characterdd
to delete a line
u
undoctrl + r
redo
You start recording by q<letter>
and you can end it by typing q
again.
Recording is a really useful feature of Vim.
It records everything you type. You can then replay it simply by typing @<letter>
. Record search, movement, replacement...
One of the best feature of Vim IMHO.
just press r https://vi.stackexchange.com/questions/305/how-can-i-rename-the-file-im-editing
just press d
https://vi.stackexchange.com/questions/9028/what-is-the-command-for-select-all-in-vim-and-vsvim