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

Автор atcoder_official, история, 6 дней назад, По-английски

We will hold AtCoder Beginner Contest 371.

We are looking forward to your participation!

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

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

Wish U to get good grade.

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

Didn't get good grade because I started with problem F at first.

How the hell could the difficulty of the questions be ranked like this? I don't want to endure until the end, so now it's the first hour of the competition that has just ended, and the current passing situation is:

A 8740 / 9353
B 8505 / 8694
C 2790 / 2918 ?
D 4159 / 4730
E 1984 / 2142
F 85 / 150 ??
G 62 / 274 ?

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

    True dude, I'm stuck on F and G. Mostly I will pass ABCDE and think for F or G and solve it (at least solve half of it) but this time I really have no idea.

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

Was the solution to G seriously to use python... lol

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

Wasted 60 minutes trying to avoid big integers, and the official solution is to use big integers.

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

my solution of E with lazy segtree. also how to solve C?

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

    Just brute force on all permutations and calculate minimum.

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

    plz explain in details how to solve it using seg tree ?

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

      first construct a prefix array where $$$ pref_i $$$ tells the answer for $$$ f(1, i) $$$. segment tree will be constructed on that. then focus on what happens when we move from $$$ i $$$ to $$$ i + 1 $$$. We're deleting the element at index $$$ i $$$. if that's the last occurence of that element then the suffix $$$ [pref_{i+1}, pref_{i+2}, .... pref_{n}] $$$ all will be decremented once because one unique element has been permanently removed. otherwise we know there is at least one $$$ j $$$ such that $$$ a_i = a_j $$$. we can find that $$$ j $$$ using binary search. the same process will happen but this time the decrement will be only occur at the part $$$ [i + 1, j) $$$. Note that j is non-inclusive. that's because at index j, everything will become normal. all of this can be tracked with lazy segment tree and range operations.

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

    E doesn't actually need lazy segtree. If you reorder the "queries" in a clever way, you can see that the seg operations reduce to simply adding one to a segment and querying total sum. This doesn't need a tree at all, and in fact doesn't require the array itself to be built. Maintaining the total sum as well as the last occurrence of each element was sufficient: https://atcoder.jp/contests/abc371/submissions/57767852

    C was bruteforce. Observe that $$$O(n! \space n^2 \log n)$$$ passes.

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

      Why logn

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

        I stored the graph edges with an std::set, so insertion / checking was logn complexity

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

          Yeah but that's kinda overkill

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

            eh, not really. I just needed to be able to check if some edge (u, v) existed in the graph, and std::set was not only faster than an O(n) search but also easier to write. Also, unordered_set wasn't an option due to lack of hash..

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

            ah shoot I see what you see about adj matrix and stuff

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

    I am solving with the exact logic you have mentioned but using fenwick tree but it isn't behaving like I want it to, Am I implementing the fenwick tree wrong?

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

      Are you sure that fenwick tree supports range updates? I don't have good experience with them

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

E is way too easy for 475.

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

E is just one google search away, literally the first search result

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

can anyone please explain E? Can't understand editorial.

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

    Here's what I did:

    First I realized that the approach simplified if I considered the sum of all subarrays ending at position $$$0$$$, then at position $$$1$$$, etc. For example, let's say that the array $$$a = 1, 2, 3, 2$$$

    For each subarray of $$$a$$$, define the array $$$b$$$ to be all the $$$f(i, end)$$$ for all $$$i$$$. In the subarray $$$1, 2, 3$$$, then $$$b = 3, 2, 1$$$. There's a pattern in how each $$$b_i$$$ transforms to the next one:

    $$$b(1, 2) = 2, 1, 0, 0$$$

    $$$b(1, 2, 3) = 3, 2, 1, 0$$$

    $$$b(1, 2, 3, 2) = 3, 2, 2, 1$$$

    The pattern I noticed is that each added number $$$i$$$ increases all the values of $$$b$$$ between $$$i$$$ and the last occurance of $$$i$$$. It turns out that we don't actually need the array to be stored at all, and can just store and update the total sum of $$$b$$$.

    My code here: https://atcoder.jp/contests/abc371/submissions/57767852