jt.cheng26_orz's blog

By jt.cheng26_orz, history, 7 weeks ago, In English

I will start:

Round #720 Div. 2 for the steep difficulty jump between B and C (1300 to 2000)

Round #698 Div. 2 for the mass FSTs (13382 out of 37306 submissions that passed pretests according to CF API, Ratio: 35.871%)

Read more »

 
 
 
 
  • Vote: I like it
  • -35
  • Vote: I do not like it

By jt.cheng26_orz, 2 months ago, In English

Both scanf/printf and cin/cout (with stdio sync optimization on) are pretty fast on their own. However, there is a way to keep the easy grammatical syntax of cin/cout while still obtaining a 4x speedup.

Firstly, let us look at the functions getchar_unlocked() and putchar_unlocked(). These functions provide an immense speedup to the default getchar() or putchar() functions, which are already fast themselves. The following class/template will wrap those functions, and with overloaded << and >> operators, we can easily replicate the syntax of cin and cout.

Template, just copy paste this into your program

Unfortunately the FastIO class cannot read doubles, if anyone could offer advice that would be great!

This was tested on Ciel and Gondolas, which is a very input heavy problem. The FastIO class passed with 872 ms, while optimized cin/cout passed with 3212 ms, and scanf/printf straight up TLE'd.

Read more »

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