BARBARIANNNNN's blog

By BARBARIANNNNN, history, 2 years ago, In English

There is a strange thing between C++14 and C++20

We can see that the down two code are same, but the code using C++20 got TLE, and the code using C++14 got AC

https://codeforces.com/contest/1634/submission/145631828

https://codeforces.com/contest/1634/submission/145633066

We can also see that the down two code are same, but the code using C++14 got TLE, and the code using C++20 got AC

https://codeforces.com/problemset/submission/573/145373496

https://codeforces.com/problemset/submission/573/145372752

What's wrong with it? It there anyone could help me answer the question? Many Thanks!

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

| Write comment?
»
2 years ago, # |
  Vote: I like it +8 Vote: I do not like it

in the second case, it is due to the 64-bit version of the compiler.

»
2 years ago, # |
Rev. 2   Vote: I like it +3 Vote: I do not like it

C++20(64-bit) is absolutely faster than C++20.

One of my friends named EasonTAO debugged the whole night and submitted for 94 times and got all TLE because he used C++20. Later he used C++20(64-bit) and submitted the same code and got AC.

It was really surprising.

Here is his submission.

143979222

  • »
    »
    2 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    That's really amazing that C++(64-bit) can run so fast.

    • »
      »
      »
      2 years ago, # ^ |
        Vote: I like it +5 Vote: I do not like it

      hahaha I used C++17(64-bit) and got AC while it's O(N^2) and N=1e5 :)

      • »
        »
        »
        »
        2 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        That's true. It seems that legacy problems can be passed with even the naive solution.:)

      • »
        »
        »
        »
        2 years ago, # ^ |
          Vote: I like it +24 Vote: I do not like it

        hahaha I used C++17(64-bit) and got TLE while it's O(N^2) and N=1e4 :)

  • »
    »
    2 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    NO,I got TLE because I used C++14,Two hours later,I used C++17(64 bit) and submitted the same code and got AC.

    • »
      »
      »
      2 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I'm very suprised when I got AC.

      • »
        »
        »
        »
        2 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        I was very surprised at that time too.

        By the way, using O3 is also important when you are dealing with a qualmish problem.

        • »
          »
          »
          »
          »
          2 years ago, # ^ |
            Vote: I like it +77 Vote: I do not like it

          Why not Ofast

          • »
            »
            »
            »
            »
            »
            2 years ago, # ^ |
              Vote: I like it -13 Vote: I do not like it

            There is Ofast too

          • »
            »
            »
            »
            »
            »
            2 years ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            I used O3,O2,Ofast and many other amazing things

            • »
              »
              »
              »
              »
              »
              »
              2 years ago, # ^ |
                Vote: I like it 0 Vote: I do not like it

              You used the O3 I gave to you

        • »
          »
          »
          »
          »
          2 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          At that time I was suprised that cin is faster than scanf!

          • »
            »
            »
            »
            »
            »
            2 years ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            yeah, and also faster than read(int &x) once I got TLE(501ms) while using read() :(

            • »
              »
              »
              »
              »
              »
              »
              2 years ago, # ^ |
              Rev. 2   Vote: I like it +5 Vote: I do not like it

              Someone's "Fast Read":

              int fread(){
                  int x;
                  cin>>x;
                  return x;
              }
              

              ()()()

»
2 years ago, # |
  Vote: I like it -19 Vote: I do not like it

EasonTAO, yyds!