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

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

Contest link : https://codeforces.me/gym/102942

Announcement link : https://codeforces.me/blog/entry/87209

Finally, The round is over smoothly :) We hope everyone had fun and enjoyed the contest!

A. Directional Move

Tutorial
Solution
Tester Solution

B. Make All Odd

Tutorial
Solution

C. Team

Tutorial
Solution
Tester Solution

D. XOR Game

Tutorial
Solution
Tester Solution

E. Password

Tutorial
Solution
Tester Solution
Tester Solution 2

F. Offer

Tutorial
Solution
Tester Solution

-If have any more query, then please comment.

Разбор задач Noobs Round #2 (Div. 4) by Rudro25
  • Проголосовать: нравится
  • +129
  • Проголосовать: не нравится

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

thanks for this contest and hope for more contest like this.

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

Great round. For D, if x and y have no common bits then answer is NO else YES. So this will also work

if(x & y) cout << "Yes";
else cout << "No";
»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Thanks for the round and quick editorial

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

Thanks for the round waiting for the next one

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

Hoping to solve upto D in div2 contest also some day. btw thanks for this contest and hope for more contest like this.

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

Nicely done, thanks for the contest!

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

E was really a good problem for learning dp, thanks for the round.

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

We can also solve E with combinatorics. Combination with repetition to be exact. Suppose the string is like, 1----5. We can place any digit from this, {1,2,3,4,5} set in increasing order in 4 place between 1 and 5.

Let, n = number of place to fill. m = size of the set. Possible ways will be (n+m-1) Choose n.

For practice: https://codeforces.me/contest/1288/problem/C

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

Thanks for the contest, had fun doing it!

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

Please make the submissions public, or atleast the testcases. It helps a lot in debugging silly mistakes.

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

Could anyone explain F in a more detailed way? It would be much appreciated.

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

    It's just 2 pointer approach, we can keep on increasing our right pointer while maintaining frequency and cost, until the cost becomes greater than k. At this point we can start incrementing our left pointer and decreasing the cost. The number of elements will right-left+1. Now we keep on repeating the prcoess.

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

If in problem D, we were asked to maximize the score of Bob, how will we solve it ?

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

The contest was great! Although I had come up with a similar idea as editorial, I had a hard time proving D during contest. I still can't wrap around why case 2 always is true. Could anyone please explain?

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

Nice Contest..problem set was really good.

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

Very nice contest! Want more! Especially thanks for the good E task.

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

The F can also be solved using the bit + binary lifting technique.

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

can you please add more test cases? bacause it is just checking with one test case and getting accepted?

so now i don't even know whether my solution is correct or not?

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

For C, why is the following approach incorrect? Answer is at least equal to elements >=k. Now put other elements in a list and sort it. Now iterate over every element, for every a[i], use lower_bound() on k-a[i] in range [i, list.size()] to find if such element exists. If it does, mark it used and increment answer. Why does this give a WA?

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

Let's consider a variation of problem F. Now in the subsegment [l,r] instead of making the cost of all repeating elements in that subsegment zero if we were allowed to take only one of the repeating elements in that subsegment and make its cost equal to zero. Rest all the conditions remain same as mentioned in the problem F. Then can someone please provide an insight on how we could have solved it.

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

Hello , Thanks for this Contest . Can you Please Update the Settings so that we can we view all the test case , My Code for F gave wrong answer on test case 3 but I cannot access that test case . Thanks .

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

We need more contests like this. Contests like today's destroy us and you pick us up. Thanks for organizing this man!

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

So, my understanding of the solution of $$$D$$$ is as follows:

If $$$a$$$ and $$$b$$$ are given such that there are no common bits between them, the answer is $$$NO$$$, because there are no 2 integers $$$1 \leq c \leq a,$$$ $$$1 \leq d \leq b$$$ s.t. their xor will be strictly greater than the xor between $$$a$$$ and $$$b$$$.

If $$$a$$$ and $$$b$$$ are given such that there are common bits between them, the answer is $$$YES$$$, because we can always find 2 integers $$$1 \leq c \leq a,$$$ $$$1 \leq d \leq b$$$ s.t. their xor will be strictly greater than the xor between $$$a$$$ and $$$b$$$.

But I don't understand why this should always be true (i.e. for 2 integers $$$a$$$ and $$$b$$$ s.t. there are common bits between them, why is it that we can always find 2 integers $$$1 \leq c \leq a,$$$ $$$1 \leq d \leq b$$$ which don't have common bits between them, s.t. their xor will always be strictly greater than the xor of $$$a$$$ and $$$b$$$), can anyone please provide a more detailed explanation of this or a proof?

Edit: deleted some erroneous stuff I thought was correct..; also, thanks a lot @doubleux, that last paragraph (especially) really made it very clear and obvious that the "strategy" for the solution of $$$D$$$ would always work.

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

    Notice, that the maximum Xor between any two numbers is always less than their sum, the maximum arising when no two bits are common.

    Thus, if no bits are common, Xor of a and b is a+b, which is maximum that you can get using numbers less than them. Therefore no pair possible in this case.

    If the do have common bits, a Xor b will be 0 at that position. Now choose c same as a, while for d, change the bit at common position as 0. This will make that bit 1 in their bitwise Xor, thus making it larger.

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

I used the same logic and approach in F but got TLE, why Python why :'-)

Problem F submission

Great tasks tho!

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

I used the chorus property. a^b=c -> a^c=b so (c^d = (a^b)+somenum) -> (c^((a^b)+somenum)=d) And did 1<=somenum<=10. But why +10 was enough I don't understand. can open my eyes?

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

IGNORE

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

Video tutorial for problem D: https://youtu.be/y2ERMJFsyjg

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

please conduct more these type of contest . This is very helpful for beginners.