potatoArmy's blog

By potatoArmy, history, 2 months ago, In English

Problem 1: 2263C1 - Floor of MEX (Easy Version)

$$$O(n^2)$$$ solution: 390532511

Code

kondasujay2 CutSandstone sukon

Problem 2: 2269C - K Is Important

$$$O(n^2)$$$ solution: 392233470

Code

Hamed_Ghaffari sweetweasel eren__ _R00T

The reason? Because of $$$n \le 10^5$$$, not $$$2 \cdot 10^5$$$, PLEASE all future authors use $$$n \le 2 \cdot 10^5$$$ PLEASE

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

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

Are these really n^2 if the first one ran in 46ms? Also killing brute / heuristic solutions I think is a part of the testing process. I gave up and tried to submit an AVX solution to d1C this morning and it made it to pretest 11 but died then

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

Not crazy enough. Just watch this, We can solve *3100 in $$$O(n^2)$$$ with AVX.

»
2 months ago, hide # |
← Rev. 3  
Vote: I like it -24 Vote: I do not like it

code 1: use difference array, too trivial optimization it doesn't matter

code 2: an optimization would be using fenwick tree to count erased elements, but it's clearly overkill for c div 2 and is probably a nontrivial optimization

also the same problem happened in 1425I, 2242F, 1777F (1 sec for AVX out of 8), etc...

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

Can someone tell me what is exactly AVX? And why it would make a difference when n<=2e5?

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

    AVX is a specific version of SIMD (single instruction multiple data)

    It lets the computer perform 512 (or 256, if your processor is extremely old) bit of operations at once. I.e, it can perform 16 32-bit operations in one clock cycle. This essentially decreases constant factor by a factor of 1/16 so a solution running in 16s will run in 1s. Of course the improvmenet is not going to be exactly like this but it allows some cheese strats.

    It is similar to how Bitset lets you perform 01 Knapsack in O(n²/64) (the computer operates on 64 bits at a time which is 64x faster)

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

n = 1e5 is the annoying cutoff. Same loop at 2e5 is an obvious TLE, and at 5e4 nobody cares. 1e5 is where a sloppy n^2 still sneaks under 2 seconds and then the comments turn into SIMD arguments.

»
2 months ago, hide # |
 
Vote: I like it -10 Vote: I do not like it

I think in both of those problems, I solved using a segment tree lol.

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

Not entirely related, but a solution in n*q with n and q<=200000 AC in an IOI problem https://oj.uz/submission/826888