TLE with C++17 but AC with C++14 [UWCOI20D]

In yesterday’s contest, I wrote a solution for this Problem

When i submitted in C++17, It gave me TLE for the last case, and i spent over 20 mins optimizing the code but no luck.

Then I copy paste and submit it in C++14, and magically the verdict changed to AC.

C++17 Code TLE
C++14 Code AC

These two codes are copy-pasted

Is this normal? anyways i won’t use C++17 ever now XD

Sometimes this happens for me in codeforces,surprising to know that it happened in codechef .

This is my first time experiencing it lol, it (almost) screwed up my contest yesterday because i wasn’t able to figure out what’s wrong

Similar to this

Your code runs in 0.89 seconds on C++14 and in 1.02 seconds on C++17. This amount of difference is not surprising, and is in no way evidence that C++17 is slower in general. There are definitely many codes which run slightly faster in C++17 than in C++14.

6 Likes

Thanks I didnt knew cc started supporting c++17.

2 Likes

Please consider making an announcement that codechef started supporting c++17. With an exact command line which you use. Whether or not you are using this patch. I didnt knew C++17 exists until I read this post.
E.g.- Mike added this post Codeforces: Welcome, C++17! - Codeforces

1 Like
  1. It seems I cant submit older problems using C++17. E.g. - I wanted to resubmit SONGIF Problem - CodeChef and few other problems. I’m assuming migration to C++17 is still WIP.

  2. Submissions on INTEST problem says cin/cout of C++17 is ~25% slower than C++14.
    On the other hand printf/scanf of C++17 seems ~25% faster than C++14
    One more thing I noticed that cin/cout in general on this problem was faster than printf/scanf. Best combination among all was using cin/cout on C++14.
    Which kills my plan of using C++17 on Codechef.

  3. Also, I use some pragmas on Codechef and these when submitted using C++17 gives me compilation error. Idk what they do but right now I’m not confident removing them.

My Pragmas
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
  1. Also, there are problems where C++17 is a faster than C++14.
2 Likes

So should we use c++14 in codechef?

I’m planning to use both on near ACs in longs. For subs which a getting TLE due to delta difference.
In general C++17 us supposed to be faster. Idk why its taking more than C++14 on that problem.

1 Like

ok thanks :slightly_smiling_face:

I checked your submissions for both c++14 & 17. As of now both are AC. Did you changed the links? Also the c++17 submission is faster in given link. for c++14 - 0.89secs while c++17 - 0.39secs. I am reading this on 2 May like after 3 months past the original post. How does the submission status is changed I dont understand. ;(