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

Автор awoo, история, 5 лет назад, По-русски

1620A - Equal or Not Equal

Идея: BledDest

Разбор
Решение (Neon)

1620B - Triangles on a Rectangle

Идея: BledDest

Разбор
Решение (awoo)

1620C - BA-String

Идея: BledDest

Разбор
Решение (awoo)

1620D - Exact Change

Идея: adedalic

Разбор
Решение (adedalic)

1620E - Replace the Numbers

Идея: Neon

Разбор
Решение 1 (Neon)
Решение 2 (Neon)

1620F - Bipartite Array

Идея: BledDest и Neon

Разбор
Решение 1 (Neon)
Решение 2 (Neon)

1620G - Subsequences Galore

Идея: BledDest

Разбор
Решение (BledDest)
  • Проголосовать: нравится
  • +66
  • Проголосовать: не нравится

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

In my opinion, I think that the positions of E and D should have been swapped.

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

In the problem E-Replace the Number, alternate solution mentions the small to large method. Can anyone explain how it has complexity of O(n log n)? Any resource added would also be helpful.

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

I have upsolved E using map of list as merging list is O(1).

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

Mike, please please remove cheaters, I am at 1899

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

I upsolved E using map of list as merging list is O(1) operation.

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

Can someone please explain why this DSU based solution for E is failing TC 4?
I am using a hashmap and a pointer array to map the representatives to the values and vice-versa; and everything seems to be working fine.
My Submission.

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

In case you are interested in video solutions, Here they are(for A-E)

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

In C , are there any constraints on the total number of strings possible ? Will it be always in the INT range ?

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

Getting TLE in Problem E, with this solution. Can somebody tells why because it seems more efficient than one in the solution 2 of tutorials.

https://codeforces.me/contest/1620/submission/139879128

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

    TLE because of how you are processing your 2nd type of querry.

    consider 10^5 querries of 2nd type like

    2 1 2

    2 2 3

    2 3 4

    ....

    that is in the end converting all 1 to some large number

    if the vector containing index of 1 has 10^5 elements

    Do you see where you are going wrong?

    10^5 x 10^5 operations there is your TLE

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

https://codeforces.me/contest/1620/submission/139877833 Can someone explain why this submission gives TL on E? It should be O(n) since double-linked list concatenation is O(1) operation... Thanks.

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

In problem E why my solution is wrong this one.any suggestion or testcase

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

Can someone tell me some similiar problem as E, or some algorithm tag?

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

In the editorial of D,

no need to take more than $$$3$$$ coins $$$1$$$ and more than $$$3$$$ coins $$$2$$$

I think you meant,

no need to take more than $$$2$$$ coins $$$1$$$ and more than $$$2$$$ coins $$$2$$$

Because, in the given solution code, you are iterating from $$$i = 0$$$ to $$$i \lt 3$$$. And, I have also done the same :)

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

C problem is really amazing. And the solution is lot more amazing.

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

I have a different solution to F

following the editorial, there can't exist $$$i \lt j \lt k$$$ such that $$$a_{i} \gt a_{j} \gt a_{k}$$$. if an array satisfies this condition then the array can be decomposed entirely into two or less increasing subsequences.

Proof: consider doing a pass through the array and greedily picking out an increasing subsequence. Do two such greedy passes through the array let $$$S$$$ be the sequence chosen by the first pass and $$$T$$$ the sequence chosen by second pass. Assume there exist an index $$$k$$$ that isn't chosen by either sequences pick such smallest $$$k$$$, indexes $$$1$$$ to $$$k-1$$$ can't be all in $$$S$$$ otherwise $$$k$$$ would be in $$$T$$$, this implies there exist an index $$$i$$$ with $$$i+1$$$ < $$$k$$$ such that $$$i$$$ is in $$$S$$$ and $$$i+1$$$ is in $$$T$$$. Pick $$$j$$$ such that all indexes from $$$i$$$ to $$$j$$$ are in $$$T$$$ but $$$j+1$$$ is not. then $$$a_{i} \gt a_{j}$$$ otherwise some index between $$$i+1$$$ and $$$j$$$ would had been chosen by $$$S$$$ and $$$a_{k} \gt a_{j}$$$ otherwise $$$k$$$ would have been chosen by $$$T$$$ so we get $$$a_{i} \gt a_{j} \gt a_{k}$$$ which is impossible. For the other direction if there exist a length 3 decreasing subsequence then all three must be in different increasing subsequences.

Great!now we can construct a dp that tries to builds two or less increasing subsequences. Let $$$dp_{0 / 1,i}$$$ be the minimum possible value of the end of the increasing subsequence that $$$i$$$ is not part of(consider the end of the subsequence to be $$$-\infty$$$ if its empty) , $$$0/1$$$ denotes whether we choose to flip the sign of $$$p_{i}$$$, the transitions are deciding whether or not to stick $$$p_{i}$$$ into the same subsequence as $$$p_{i-1}$$$ ,the answer is yes if either $$$dp_{0,n}$$$ or $$$dp_{1,n}$$$ $$$\neq\infty$$$

my submission :140109080 (in hindsight the dp I described should be equivalent to the editorial dp, but I think this interpretation is cleaner and easier to understand)

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

please can someone tell me why is this code failing for C ?? https://codeforces.me/contest/1620/submission/140169385 I have lost my mind at debugging this for 3 hours at this point,also is there a way to see the full testcase in this website ?

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

Nice problems

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

In problem C, for this test case

TC:
                1
                8 3 18
                a***a*

The output of the editorial code is abbabbb i.e; (2+1) * (3+1) => 12th lexicographically smaller but I asked for 18th right. How is this correct?

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

    Your test has n=8 and the string is length 6 — something is wrong.

    However, that's not how you obtain the number from its digits. Consider base 10. If you have a number, consisting of digits 1, 2 and 3, then this number is 1 * 10 * 10 + 2 * 10 + 3. Same here. You have a number, consisting of digits 2 and 3 (the lengths of b segments in the answer). Thus, the number is 2 * (3 + 1) + 3 = 11. So this is the 12th string but if n was equal to 6 in your test.

    If the string instead was *a***a* and the answer was babbabbb, then the number would be retrieved as 1 * (3 + 3 + 3 + 1) * (3 + 1) + 2 * (3 + 1) + 3. So you have to multiply each digit by the bases of lower digits and add up the results.

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

I really dont understand the problem D. Why there is no need to take more than 3 coins 1 and more than 3 coins 2? In my opinion, there is no need to take more than one coin 1 (i.e. one coin 1 at most) because if any ai required two coins 1, two coin 1 could be replaced by one coin 2; and ,similarly, there is no need to take more than two coins 2. This really confuses me. Could anyone explain it? Thanks in advance!

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

I solved E using Linked list in O(n) https://codeforces.me/contest/1620/submission/141979731

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

Does anyone know why this solution to E is getting an MLE on testcase 4? 143353188

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

Edit: I see why because of this link: https://codeforces.me/blog/entry/64625 check it. Problem G: Some contestant solved this problem using inclusion-exclusion, let cnt be the number of strings that are subsequence of the strings given by the mask, they do +cnt when the amount of bits is odd and -cnt when is even. Then, they do dp[mask] = cnt and apply SOS DP at the end. SOS Dp is clear, but what is the argument of that inclusion-exclusion when adding and decreasing depending on the bits?

Sorry for my English, thanks in advance.

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

why are constraints on $$$G$$$ so massive? is this to block out $$$O(3^n)$$$ solutions or something?