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

Автор ACGN, история, 2 года назад, По-английски

In Codeforces, there are all sorts of intelligent minds: mathematical, algorithmic, and creative minds all come together under one website to create a beautiful platform.

Hold up, there’s still something missing, a gap that, if filled, would make the platform truly marvelous.

Literature.

Most of the code on this platform is robust and correct. But they aren’t beautiful. #define mp make_pair? What even is "mp"? This is almost sacrilegious.

They don’t add to the literary beauty of this otherwise great platform.

#defines aren’t meant to be used this way. Nor are they meant to encode cryptic text like this submission.

The purpose of #defines are to make Codeforces show its literary beauty, the beauty otherwise obscured by confusing syntax.

This is a beautiful excerpt of Shakespeare. Looking at the actual text is pure eye-candy.

This is what #defines are for. Not to make confusing code even more confusing, but to make beautiful code even more beautiful.

From now on, keep this inner beauty of CP in mind; when solving problems, try to let out your inner literary mind, and quote from the literary giants.

To beauty or not to beauty, that is the question problem.

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

»
2 года назад, # |
  Проголосовать: нравится +150 Проголосовать: не нравится

#define int long long

ugly

  • »
    »
    2 года назад, # ^ |
    Rev. 7   Проголосовать: нравится -33 Проголосовать: не нравится
    #define int long long
    

    is very useful

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

      Only when the memory limit and the time limit of the problem aren't tight. Otherwise, it will increase both time and memory by almost 2 times.

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

        Please stop saying that time gets 2x increment. I read this like 1e9 times every week. It "used to be the case" when judges only had 32 bit compilers because each 64 bit integer used to go around with 2 clock cycles. Now with 64-bit compilers, the single clock is efficient and the speeds are more of less same.

        • »
          »
          »
          »
          »
          2 года назад, # ^ |
          Rev. 2   Проголосовать: нравится +25 Проголосовать: не нравится

          I dont understand, how do you explain this then

          Using long long, TLE: 151025283

          Using int, AC (499/1000 ms): 151047340

          edit: mixed up order, now fixed

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

            i'd imagine it's something to do with cache accessing being able to fit more 32 bit integers? that's my reasoning for whenever i switch from ll to int for a speedup anyways

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

              This is one of common reasons, but it rarely leads to 2x slowdown. In this case it's about instruction latency/μops. 64-bit division is slower than 32-bit on most architectures, including Intel Skylake, which, AFAIK, is used by Codeforces. Check idiv in instruction timings

              Replacing long long with int only for modulo operations, AC: 151587678

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

          The reason I wrote this comment was that there was this problem(I don't remember exactly) I kept getting TLE and I couldn't figure out the issue. After like 2 hrs of debugging I tried changing every element that can be int from long long and it got AC. It was a very frustrating experience and I just wished that people who read this comment don't struggle for a few hours like me. (no offense intended.)

    • »
      »
      »
      2 года назад, # ^ |
      Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

      Even though it is useful,it makes code ugly and less readability.
      Personally,I choose typedef.

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

    Improved: 151474510

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

    how about #define long long int?

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

      It doesn't compile.

      program.cpp:5:20: error: two or more data types in declaration of 'll'
          5 | #define  long long int
            |                    ^~~
      program.cpp:13:9: note: in expansion of macro 'long'
      
»
2 года назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится
»
2 года назад, # |
  Проголосовать: нравится +14 Проголосовать: не нравится

rainboy would approve

»
2 года назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

You can use this or this.