YF_YUSUF's blog

By YF_YUSUF, 5 months ago, translation, In English

tierlist

Link to tierlist

You can add your defines in the comments, I will add interesting to the tierlist.

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

»
5 months ago, hide # |
 
Vote: I like it +5 Vote: I do not like it

#define int long longis definitely S tier

  • »
    »
    5 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    +1 TLE

    • »
      »
      »
      5 months ago, hide # ^ |
       
      Vote: I like it -24 Vote: I do not like it

      Actually define int long long doesnt make your code slower in any way , it just makes memory more. I guess thats because of compiler optimizations.

      • »
        »
        »
        »
        5 months ago, hide # ^ |
         
        Vote: I like it 0 Vote: I do not like it

        then, +1 MLE.

      • »
        »
        »
        »
        5 months ago, hide # ^ |
         
        Vote: I like it 0 Vote: I do not like it

        On some computer that doesn't support 64bit they emulate that behavior with 32bit integers which costs way more CPU cycles.

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

        Can you please stop spreading misinformation so confidently?

        1. At the level of individual instructions, 64-bit idiv (emitted for the integer operations / and % in C++) is significantly slower than 32-bit idiv on x86-64 (a >= 2x difference in latency on some microarchitectures (32 bit latency table vs 64 bit latency table)).
        2. The data cache gets effectively halved (wrt number of elements you can fit) and this can lead to huge slowdowns in programs where memory access is the bottleneck (which is very frequently the case in CP problems).
        3. If your program has a lot of auto-vectorization done by the compiler underneath, you'll now be processing half the number of elements per vector instruction that you could have (this difference will show up even for operations like add and xor that don't have a difference in latency between their 32 and 64 bit scalar versions).
        4. Less importantly for this discussion, 64 bit instructions result in larger object code, which worsens instruction cache efficiency too.
        • »
          »
          »
          »
          »
          5 months ago, hide # ^ |
           
          Vote: I like it +1 Vote: I do not like it

          You might be right I am not an expert on the topic. Its just for me those points didnt mattered in the practice. Usually when I submit with define int long long i just get more memory and runtime stays roughly same.

          As an example i used the last contest's C, my tight n^2logn solution (which got TLE with sets and got AC with priority_queues) ran even faster by 100ms when I used define int long long (it is probably faster because servers are overloaded in contests). I dont know if it is a special case but I really didnt cherry picked it , and this has been my experience with define int long long generally. I would really like to know if there is a case where define int long long makes the runtime significantly worse (excluding the case where memory becomes too high and causes TLE).

          here are the submissions I mentioned:

          https://codeforces.me/contest/2222/submission/372495229

          https://codeforces.me/contest/2222/submission/372618056

          • »
            »
            »
            »
            »
            »
            5 months ago, hide # ^ |
             
            Vote: I like it +1 Vote: I do not like it

            actually I tried the same with F , and it was slower by roughyl 200ms so I think you are right:

            https://codeforces.me/contest/2222/submission/372619351

            https://codeforces.me/contest/2222/submission/372619285

            • »
              »
              »
              »
              »
              »
              »
              5 months ago, hide # ^ |
               
              Vote: I like it +1 Vote: I do not like it

              Here are some code snippets that you can run in custom invocation (use g++ 20) where uncommenting #define int int64_t makes a huge difference in runtime (courtesy gpt, im too lazy):

              just division/modulo
              going through big arrays
»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

itn = int , sigma = signed and int = long long is 100% S+ tier

»
5 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

This is 100% S+.

#define ll long long

#define all(x) x.begin(), x.end()

#define rall(x) x.rbegin(), x.rend()

#define yes cout << "YES\n"

#define no cout << "NO\n"

#define debug cout << "Debug\n"

»
5 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

#define int23_t long long definitely traumatized me...

»
5 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

S+ defines which i use
D all the rest

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

#define pofik continue in c tier is crazy

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I do #define long long long because I like being chaotic

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

S+ tier

// ultrakill reference???
#define gabriel cout<<"Machine,\nI will cut you down,\nbreak you apart,\nsplay the gore of your profane form across the STARS!\nI will grind you down until the very SPARKS CRY FOR MERCY!\nMy hands shall RELISH ENDING YOU\nHERE\nAND\nNOW!"; 
// brutal diff gabriel 2 in 45 secs p rank
#define int long long
#define endl '\n'
#define all(v) v.begin(),v.end()
#define idc continue
#define itn int
#define I i
#define ,= <=
  • »
    »
    3 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it
    #define endl '\n'
    

    really stops it from being anything but a disappointment

  • »
    »
    3 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    in interactive problems

    should use endl it flushes automatically and personally $$$'\n'$$$ is more suitable for typing

»
5 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I'd go for #define ll int

»
5 months ago, hide # |
 
Vote: I like it +9 Vote: I do not like it

I generally prefer doing something like using ll = long long; (actually, using ll = int64_t;) instead of #define ll long long because the later option doesn't admit functional style casts (in other words, long long (val) does not compile). Also, semantically speaking it is much nicer.

Additionally, #define int long long is quite evil from my perspective and I only use it in worst case scenarios. The reason why I don't appreciate it is that it admits laziness in terms of reasoning about types. Reasoning about types can often make you understand the problem and your solution better, which means that fixing bugs later on becomes easier (that is to say, if you have a better understanding, your code becomes more "maintainable" for you).

»
5 months ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

I used to have this:

#define FOR1(a) for (ll _ = 0; _ < ll(a); ++_)
#define FOR2(i, a) for (ll i = 0; i < ll(a); ++i)
#define FOR3(i, a, b) for (ll i = ll(a); i < ll(b); ++i)
#define overload3(a, b, c, d, ...) d
#define FOR(...) overload3(__VA_ARGS__, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define RFOR1(a) for (ll _ = ll(a) - 1; _ >= 0; --_)
#define RFOR2(i, a) for (ll i = ll(a) - 1; i >= 0; --i)
#define RFOR3(i, a, b) for (ll i = ll(b) - 1; i >= ll(a); --i)
#define overload3_r(a, b, c, d, ...) d
#define RFOR(...) overload3_r(__VA_ARGS__, RFOR3, RFOR2, RFOR1)(__VA_ARGS__)

The usage is like:

FOR(n) // iterates n times
FOR(i, n) // iterates i = 0 to i = n-1
FOR(i, 1, n+1) // iteraties i = 1 to i = n

And you can use the same thing to iterate backwards by using RFOR. As it was not really a good practice, I stopped using it lol.

»
3 months ago, hide # |
 
Vote: I like it +14 Vote: I do not like it

The best one for me was:

#define victor vector<int>
»
3 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

The defines in this submission should be on S++ tier.

»
3 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Wait, no body uses typedef?

»
3 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

how can i get this ranking/order that you made,
when i click cf's image it has very few pixels.
when i click the tierlist link it is not ranked

»
3 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

One of my define:

#define fast_io ios_base::sync_with_stdio(false); cin.tie(0);

#define pb push_back