bsdsdb's blog

By bsdsdb, 10 months ago, In English

That was the way I used to build a centroid tree (a tree that connects all the adjacent centroids during centroid decomposition, used in 342E - Xenia and Tree):

That

Then I found there were too many for (ll i : e[x]) if (i == pr || vis[i]) continue;s, so I used a macro to do shorten them:

them

This reduces my code for about 150 bytes. But what I'm worrying now is: will macros increase the difficulty to debug my code, especially in some on-site contests, where templates are not allowed?

I also used #define mid ((lx+rx)>>1) #define l(x) ((x)<<1) #define r(X) (l(x)|1) in segment tree for months btw

  • Vote: I like it
  • +14
  • Vote: I do not like it