Codeforces and Polygon may be unavailable from December 6, 19:00 (UTC) to December 6, 21:00 (UTC) due to technical maintenance. ×

Probka's blog

By Probka, history, 6 hours ago, In English

I'm not gone to talk about popular templates as typedef long long ll; or typedef vector<int> vi;. I want to share some of mine templates, which I don't see vary often from other people, but think that this templates are very usefull.

It is often necessary to write something like x = max(x, something), and I would like to have a syntax like x max= something. I use this define for this.

#define cmax(u, v) u = max(u, v)
#define cmin(u, v) u = min(u, v)

Sometimes I forget that the solution in int does not work. And in order not to rewrite it, I will uncomment this define.

// #define int ll

Often the vector reading code looks the same, so I made a template function for this.

template<typename ValueType>
istream& operator>>(istream& in, vector<ValueType>& vect) { fore(vect) in >> val; return in; }

Also, for those who are interested, here is my complete template(someday I'll post it on github with all my DS and other stuffs, someday:D). Maybe you can learn something for yourself or give me some advice.

My entire template

And there is an ASKII art at the end of my template. But due to the fact that it is too big for the post, it's just screenshot.

ASCII art
  • Vote: I like it
  • +3
  • Vote: I do not like it

»
6 hours ago, # |
  Vote: I like it +3 Vote: I do not like it

Why not use

#define f(o, a, b) a = o(a, b)

//use like
f(max, p, q)
f(min, g, h)

to maximise ugliness