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

Автор pritishn, 5 лет назад, По-английски

For the Grid Paths problem, if I use #define int long long and submit the solution, it gets accepted verdict, but using int gives time limit exceeded. How is this possible?

Link to accepted with long long : https://cses.fi/paste/6c2a837ed715717813be49/
Link to TLE with int : https://cses.fi/paste/1298e773dc80a66513be46/

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

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

Run it locally and measure the time. Maybe both versions are close to TL and you just got lucky once.

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

    I ran them locally 5 times ..
    flags : -Wno-unused-result -O2 -std=c++17

    using int
    0.74103 sec
    0.756871 sec
    0.79994 sec
    0.738276 sec
    0.733718 sec

    using long long
    0.691453 sec
    0.68186 sec
    0.689874 sec
    0.697802 sec
    0.683085 sec

    How can the long long version be faster? Have you ever encountered something like this?