JurCai's blog

By JurCai, history, 3 years ago, In English
Just Like This(Language:BrainFuck)

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

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

XD

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

could any one help me with some LIS(dp) pair vector problem , the statement we got array a of {wieghts, IQ} of elephants, we want max subset of the seq (**print seq** too) that validate w(a[i]) < w[a[i+1]) and IQ(a[i]) > IQ(a[i+1]). could any one solve it in O(n log(n))n any idea ?

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

    Hint ($$$O(n \log^2n)$$$ though)

    UPD: why downvotes?

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

      because the question is irrelevant to the blog?

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

        I meant downvotes to my answer. Btw yes, it's a good point, maybe I should have answered somewhere else.

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

I was always amused by interesting cycles, for example : for(int i=0;i<n;i-=-1)

Sorry, I didn't see a little about what code we are talking about :)

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

    You can also implement loops with the downto operator -->

    for(int i = n;i-->0;)
    
»
3 years ago, # |
  Vote: I like it +5 Vote: I do not like it

Recently I looked at python co-routines, which give a really strange way to approach problems. See https://gist.github.com/ramalho/da5590bc38c973408839 for conways game of life. Somehow, we have a function step_cell which is accessing state used in a sibling function live_a_generation, but neither method is calling another and there are no global variables. Instead, it kind of looks like two methods are running in parallel (although they aren't).

If that gist is too long for you, I also implemented 2 pointers in this same weird style and it's only about 20 lines https://codeforces.me/contest/1133/submission/131576712

»
3 years ago, # |
  Vote: I like it +15 Vote: I do not like it
DISCLAIMER: I am not responsible for mental and emotional damages contents of this spoiler might cause
  • »
    »
    3 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    2 + 3 — 1 .

    Reverse Indexing is interesting in cpp! I discovered this a few months ago. I love this concept.

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

      For C-style arrays, array indexing is equivalent to pointer arithmetic, i.e. a[i] == *(a+i), so the mystery is solved there.

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

    Now i really regret my decision! I shouldn't have opened it.

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

    Really man , what is this !! truly strange

»
3 years ago, # |
  Vote: I like it +24 Vote: I do not like it
int p[] = {-1, n};
while (p[1] - p[0] > 1) {
    p[!f(p[0] + p[1] >> 1)] = p[0] + p[1] >> 1;
}
// p[0] == largest i such that f(i) is true
// p[1] == least i such that f(i) is false
»
3 years ago, # |
  Vote: I like it +5 Vote: I do not like it

Nice zig-zag pattern in this code made using only swap XD. CODE. Most weird code for me.

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

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

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

have you written the blog to ask a real question or to show an unrelated anime picture?

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

this

(If you don't know about Chinese, just click the links.