anaconda666's blog

By anaconda666, history, 8 months ago, In English

I was stuck on this CSES question : Corner Subgrid Count for nearly 2 months, when I had already got the approach at the first view only. (It's not that I have been trying daily since the last 2 months, I got TLE and I left... bruhh — )

And I just figured out that I was not using the correct compile-time optimization (bruh-, what the hell was that). I was trying with Ofast and O3 optimizations but just do popcnt optimization and you are done. My approach (as obvious) was just break each row into bits of size 64, do pairwise-AND and tally the number of bits set in the pairwise-ANDs. Finally, add (count*(count — 1))/2 to the ans.

But I am amazed to see that how powerful a tool pragma actually is and how it can make your life easy :

TLE-ed Code
Accepted Code

If any of you got it Accepted without Pragma, I would love to hear that too

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

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

Auto comment: topic has been updated by anaconda666 (previous revision, new revision, compare).

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

wrong problem, sorry

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

Would writing a function to wrap popcnt work? There're a few other approaches to do popcnt without this instruction, but popcnt is a trivial 1-cycle operation so these weren't as fast.