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

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

We will hold AtCoder Beginner Contest 242.

We are looking forward to your participation!

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

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

Cpp20 when D:

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

What happened to the judge? It's so slow.

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

Long queue!

»
5 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится -10 Проголосовать: не нравится

for Problem C:

10,11,12

21,22,23

32,33,34

43,44,45

54,55,56

65,66,67

76,77,78

87,88,89

98,99

for n=2, shouldn't the answer be 26 instead of 25(given in question)?

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

How to solve D?

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

    For t <= 62, you can imagine finding value on a binary tree. It the ith bit of k is 0, go left, else go right; For t > 62, since we have a tons of leading zeros in k (0000...), we can do binary lifting. Submission

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

    What I did:

    First find out, which is the letter from the original string, that creates the block in which the char from the query will lie. This is realpos = pos / (1ull << it). Then determine the position inside this block, where the query will be. This is innerpos = pos % (1ull << it). (Special case for more than 63 iterations has to be implemented.)

    Now we know the letter from the original string. We take that as a base $$$B$$$. Instead of "A->BC, B->CA, C->AB." I will use "A->AB, B->BC, C->CA." now. To account for this change we add the number of iterations to $$$B$$$.

    Now we need to consider the innerpos. Which letter will be at this position? This hapens to be the count of set bits in innerpos in binary. So we just need to add __builtin_popcountll(innerpos) to $$$B$$$.

    Then $$$B$$$ is the answer. https://atcoder.jp/contests/abc242/submissions/29884835

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

Today I used Mo's algorithm for the first time.

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

How to solve H?

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

    you can write $$$E[X] = P(X \gt 0) + P(X \gt 1) + P(X \gt 2) + \cdots $$$

    $$$P(X \gt k)$$$ is just the probability that the process is not completed in $$$k$$$ steps.

    To calculate probability that the process isn't completed in $$$k$$$ steps, We can use inclusion-exclusion. That is P({1} isn't covered in $$$k$$$ steps) + P({2} isn't covered in $$$k$$$ steps) +...- P({1,2} isnt covered in $$$k$$$ steps)-P({1,3} isn't covered in K steps)-... + P({1,2,3} isnt covered in $$$k$$$ steps) + ...

    You can formally write it as : For each nontrivial subset $$$S \subseteq [1,\cdots,n]$$$ , let $$$j$$$ be the number of segments which don't intersect with $$$S$$$, add ($$$(-1)^{i+1}(\frac{j}{m})^k$$$ to the answer. Summing over all $$$k$$$ , we only need to calculate $$$(\sum_{k=1}^{k=\infty} (\frac{j}{m})^k)$$$ for every subset $$$S \subseteq [1,\cdots,n]$$$, You can use a dp to calculate number of ways to select a subset of $$$[1,\cdots,n]$$$ with size $$$i$$$ which have $$$j$$$ segments not intersecting with it.Solution

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

$$$G$$$-Range Pairing Query There is no editorial yet

$$$:/$$$

How to solve $$$G$$$? I wanted to come up with a Segment Tree solution but I failed when I wanted to find all the distinct numbers in range $$$l...r$$$.

PS : Did anyone solved it with Segment Tree? Or it has different algorithm to solve it?

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

    Just use mo's algorithm. Whenever you add a number to a range, check if the count of the number is odd, and if so add one to the answer. Similarly, whenever you erase a number from a range, check if the count of the number is even, and if so remove one from the answer.

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

For problem E I use digit DP on string. The states are dp[length][prefix_same][suffix_bigger]. Submission

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

Does anyone think that F was way harder than G?? I almost took half of my time solving F, but solved G in a few minutes as I knew Mo's algorithm(which was very lucky). Looking at the number of people who solved F and G I guess most people would have felt similarly. Or, is there a simpler solution to F?

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

    My solution involves two steps, first calculating dp[r][c][k], which represents the number of possible covering of r x c with k rooks of a same color without leaving a row nor column empty, and then the second step was just simply iterating through number of rows and columns for black rooks and white rooks, and adding the value $$$dp[r_b][c_b][b] \times dp[r_w][c_w][w] \times {n \choose {r_b}} \times {n-r_b \choose {r_w}} \times {m \choose {c_b}} \times {m-c_b \choose {c_w}}$$$ for each $$$r_w, r_b, c_w, c_b$$$.

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

      I also had a similar solution, but the process of calculating dp[r][c][k] was very complex. I guess it was what made the problem so hard

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

        Ah, there was a fairly simple transition between dp states. All you had to do for calculating dp[r][c][k] is to first add $$${{r\times c} \choose k}$$$ and then $$$\forall 1 \leq i \leq r, 1 \leq j \leq c$$$ (excluding (i, j) = (r, c)) subtract $$$dp[i][j][k] \times {r \choose i} \times {c \choose j}$$$ from dp[r][c][k]. Hope this makes sense

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

    Simple problems of advanced tricks are often easier if you already know the technique.

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

It didn't count for the contest. Makes me so sad, that was the most clutch. It was a last second debugging and panic-submission. [May I get an F?]

But also it was way to complicatly implemented from my side. I though at first this has to be digit DP with some kind of state for the second half of the palindrome. But it was more like the simplest form of Digit DP (means, interpret the first half of the string as a number) plus checking whether the palindrome created by using the first half of the string is valid. If I had just thought about E more, then I guess I wouldn't have had this time problem.

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

It seems official solution of Ex is not min-max inclusion and exclusion?

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

hello, I was getting a runtime error when I was running code on vs code for n>=10^5, submssion I didn't submit the code because of this and after that contest when I submitted It got accepted but still got a runtime error for n>=10^5 on vs code. can someone explain why?

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

How to Solve E ?? Please Explain in detail ... ;_;

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

why can't I see rankings by country?

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

    Since the last heuristic contest they've experienced server overload (or something like that) so sometimes they disabled ranking page. There also has been postponed contest around last week or two. I assume this functionality is temporarily disabled to cut performance cost, tho I'm not sure.

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

Really nice problems. For me the problems difficulty were F > D > E > G. Did anyone else felt the same way?

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

does anyone know what problem E test case for hack_01.txt is like?

nvm, i forgot to MOD before printing