BessieTheCow's blog

By BessieTheCow, history, 6 months ago, In English,

I use Microsoft Visual Studio as my IDE, so I submit my solutions here using the Visual C++ 2017 compiler. Recently, I submitted a solution to 1180D - Tolik and His Uncle which passed the pretests but TLEed on a system test. My solution (55894505) is a bit overcomplicated, but it runs in O(nm) which should be fast enough. In fact, it passes in 280ms when submitted using G++. A custom test shows that my solution takes 1029ms for the system test case which it TLEed on, and adding ios_base::sync_with_stdio(false) and cin.tie(nullptr) only decreased the time by 20ms, still over the time limit. I was only able to get AC with MSVC++ by using printf instead of cout. So for this solution, MSVC++ is apparently three to four times slower than G++.

I then did a custom test with MSVC++ 2010 instead of MSVC++ 2017, and I got 904ms without fast I/O and 842ms with fast I/O, which doesn't seem to make any sense. I got similar results with the official solution, so my code isn't the problem. According to, the command line for MSVC++ 2010 includes the /O2 flag which should optimize for maximum speed, while the command line for MSVC++ 2017 isn't shown. Why is MSVC++ so much slower than G++ here, and why is MSVC++ 2017 slower than MSVC++ 2010?

Read more »

  • Vote: I like it
  • 0
  • Vote: I do not like it