Hello! There're some data structures requires dynamically allocating memory, such as treap, splay treeans so on. In a recent contest, I saw a problem requiring those data structures, 1737G and noticed many legendary users submitted using pointers: 175023666, 175037024, 175043108 and 175054239...
But somewhat in a Chinese OJ, many people told me that pointers are way slower than using arrays(to create a global array with sufficient number of elements and simulate the pointers), and we should avoid using pointers. Even if we use pointers, we are not supposed to use operator new
, but to open a memory pool(this way is then similar to arrays). In fact, we can also notice that for the above problem, almost all Chinese users submitted using arrays: 175027760, 175218209 and 175032925...
What's your opinion on this topic? I'm currently using pointers, should I insist on using pointers or change my coding way? Any help is appreciated!
Using pointers is easier to write imo