ACGN's blog

By ACGN, history, 3 years ago, In English

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.

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

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

#define int long long

ugly

  • »
    »
    3 years ago, # ^ |
    Rev. 7   Vote: I like it -33 Vote: I do not like it
    #define int long long
    

    is very useful

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

      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.

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

        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.

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

          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

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

            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

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

              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

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

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

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

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

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

    Improved: 151474510

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

    how about #define long long int?

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

      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'
      
»
3 years ago, # |
  Vote: I like it +8 Vote: I do not like it
»
3 years ago, # |
  Vote: I like it +14 Vote: I do not like it

rainboy would approve

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

You can use this or this.

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

    neither are poetic enough though...