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

Автор awoo, история, 9 месяцев назад, По-русски

2170A - Maximum Neighborhood

Идея: BledDest

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

2170B - Addition on a Segment

Идея: FelixArg

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

2170C - Quotient and Remainder

Идея: BledDest

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

2170D - Almost Roman

Идея: BledDest

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

2170E - Binary Strings and Blocks

Идея: Roms

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

2170F - Build XOR on a Segment

Идея: BledDest

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

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

First.

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

Good F. At first I thought it needed an XOR basis, but it turned out to be a DP problem :)). Of course, you still need the theory to know that the minimum subset size is at most the number of bits in X

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

67

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

In C ,how do we know that we have to take the largest remainder and smallest quotient for the optimal answer.In contest it doesn't comes in mind.

In these type of question i get stuck in these situation,like — whether to sort in increasing or decreasing order, it will be helpful if someone drop down link of some problem like C .

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

    how do we know that we have to take the largest remainder and smallest quotient for the optimal answer

    Just greedy observation: 1) If the largest remainder can't form a pair with the smallest quotient, it can't be used at all. 2) Otherwise, the largest remainder can be paired with any suitable quotient, since other remainders have the same prefix or better. We choose the smallest for convenience.

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

    do sorting bro and check if the value doesn't exceed k

    356738757

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

    For me coming up with tightest upper bound on x was more tricky than observing that largest reminder should come with smallest quotient.

    As you can observe that for reminder R and quotient Q, x > Q*R.

    Therefore if you grow both together it wont give you optimal answer. I generally think this in terms of how many food items I can buy with limited money, so I will purchase cheaper items in more quantity. :)

    Holy cows, While writing this I realised my mistake of not writing down my thoughts clearly, now I see how easy it was to put bound on x.

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

I wonder why Pb A has all tags

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

Could anyone please explain why my solution for Problem D fails? My logic is to keep track of all the spaces where I can be placed before V (HSi), where V can be placed after I (HSxv), or where either I or V can be placed to form IV (HS). I also count the number of double spaces (DS) and adjust based on how many spaces were used to form IV pairs. I use freeHS to keep track of the number of spaces where an item can be placed to form an IV pair and will not impact the number of double spaces. After all the freeHS spaces are used up, then the number of double spaces will decrease

Submission: 351402607

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

As a newbie, I'd appreciate a bit more detailed solutions. For example in the solution for B, there's a "magic jump": if s−c≥n−1, then answer is c, on which the further is reasoning is based, but its not trivial.

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

    Not sure if this is helpful, but I struggled with that condition too and this is how I understand it.

    We need n actions exactly according to the problem statement. So we need to be able to perform n-1 more actions after doing our first c-length action.

    Intuitively, the smallest action we can do is adding 1 to a single element. Hence, given a particular array, we can at most perform S actions, where S is the sum of its elements.

    So then we need s-c >= n-1, where s-c is what we need after one c-length action, and n-1 is the actions we need to take.

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

      one another approach for B is to use binary search on answer . Firstly sort the array. Our answer will only lie between 1 to no. of non zero elements so perform a binary search that what is the maximum number of sequence length we can take for each binary search query we make the first mid no. of elements increase by 1 . Then we iterate for all numbers from 0 to mid and add the numbers arr[i] — 1 as these many more operations can be made into these elements at max.

      similiarly for elements greater than index mid we add all elements (which gives the maximum operation can be performed) if these operation exceed the n then we can store it in our answer and check for next greater sequence. check submission : 371283481

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

In 2170D, I don't understand the following explanation in the solution:

Greedy idea: let's use the maximum possible number of Is, then the maximum possible number of Vs, and only then use Xs. It's because if we replace any I with V, it increases the value by at least 3 , and if we replace any V with X, it increases the value by exactly 5.

Why does replacing any I with V increase the value by at least 3?

For instance if we have "II", the value is +2. If we replace the second I with V, we get "IV" and the value is (-1) + 5 = +4. In this case, it seems like the value is increased by 2. Am I missing something here? Thanks!

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

For People who didn't understand Editorial for B:

here is the simple explanation: first, we need to find the number of non-zero components and call it cnt. and find the sum of all the elements in an array and call it sum.

Now, lets take an example: 0 0 1 1 4

to convert it to 0 0 0 0 0 in exactly n operations, we need to know the size of the very first operation lets call size of the first operation to be x, if we do:

0 0 [0 0 3]

then sum — 3*(-1) will be the sum after performing op1, we need to check if the value of new sum >= n-1 or not, if yes then its okay, else it won't be possible to perform remaining n-1 ops

so we need to find the range for the first operation such that sum >= n-1, now since one relation was

original sum — x >= n-1

then original sum — n + 1 >= x thus our final answer is min(x,number of non-zero components (cnt as we declared it earlier));

for reference, check this: https://codeforces.me/contest/2170/submission/351669568

I hope that helps!

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

Please someone explain how to think to solution of Problem E?

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

Problem E: Could anyone please tell what's wrong in this dp — dp[I][j] -> number of binary sequences of length I, ending in j (0 or 1), having at least 1 constraint ending on or before I having only 1 block. 353003771

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

    Its a bit late but I also tried similiar thing initially with power of 2 if you check carefully there will be multiple counting cases here. You are checking for a given r then nearest l, but if you check in between block you have considered its dp too and they will intersect in some cases and you are multiple counting them

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

why F's solution the dp's j order can don't reverse,what happen here?

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

For B, why is the condition s-c >= n-1 sufficient to ensure a solution? I can see it is necessary but don't know how to prove sufficiency?

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

Le me Using Binary Search on Answer in B, which is not in the tags too ≡(▔﹏▔)≡

Here is the code