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

Автор YF_YUSUF, 4 месяца назад, По-русски

tierlist

Link to tierlist

Вы можете предложить свои define в коментах, интересные добавлю в тирлист.

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

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

#define int long longis definitely S tier

  • »
    »
    4 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    +1 TLE

    • »
      »
      »
      4 месяца назад, скрыть # ^ |
       
      Проголосовать: нравится -24 Проголосовать: не нравится

      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.

      • »
        »
        »
        »
        4 месяца назад, скрыть # ^ |
         
        Проголосовать: нравится 0 Проголосовать: не нравится

        then, +1 MLE.

      • »
        »
        »
        »
        4 месяца назад, скрыть # ^ |
         
        Проголосовать: нравится 0 Проголосовать: не нравится

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

      • »
        »
        »
        »
        4 месяца назад, скрыть # ^ |
        Rev. 2  
        Проголосовать: нравится +9 Проголосовать: не нравится

        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.
        • »
          »
          »
          »
          »
          4 месяца назад, скрыть # ^ |
           
          Проголосовать: нравится +1 Проголосовать: не нравится

          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

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

            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

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

              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
»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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

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

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"

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

#define int23_t long long definitely traumatized me...

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

S+ defines which i use
D all the rest

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

#define pofik continue in c tier is crazy

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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 ,= <=
»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I'd go for #define ll int

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

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).

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

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 месяца назад, скрыть # |
 
Проголосовать: нравится +14 Проголосовать: не нравится

The best one for me was:

#define victor vector<int>
»
3 месяца назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

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

»
3 месяца назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, b, a) for(int i = (b); i >= (a); i--)

Когда-то мне нравились такие)

»
3 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Wait, no body uses typedef?

»
3 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

One of my define:

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

#define pb push_back