Блог пользователя RestingRajarshi

Автор RestingRajarshi, 4 года назад, По-английски

Just a heads up if someone else gets this bug:

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

I usually add these two lines of pragmas in my code. But on submitting it to the POI judge, it gives runtime error 4, and when excluded, it doesn't.

Would also be nice if someone could elaborate on why Runtime error 4 is returned on passing the pragmas.

  • Проголосовать: нравится
  • +6
  • Проголосовать: не нравится

»
4 года назад, # |
  Проголосовать: нравится +16 Проголосовать: не нравится

With second pragma you allow compiler to use some assembly instructions which are not supported on some machines, and if some judge system uses different machines for compilation and execution, you may encounter such a problem. I'm not sure about POI, but with Yandex system it is exactly such case.

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится +8 Проголосовать: не нравится

    That's the case. Using pragmas is just asking for a problem in most cases imho.

    • »
      »
      »
      4 года назад, # ^ |
      Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

      Well, Ofast and sse should work everywhere. But of course, using these pragmas makes sense only if you know and understand why you need them in specific solution.