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

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

Hello, everyone! It was a delight for us to have you participate in our contest. We hope you enjoyed the problems! Here, we present to you the solutions of the problems. I have also prepared some memes for you to enjoy — disclaimer: not all of them were created by me.

Tutorial is loading...

Author of this problem was Ashishgup.

Relevant Meme
Code for A
Tutorial is loading...

Author of this problem was Ashishgup.

Relevant Meme
Code for B
Tutorial is loading...

Author of this problem was TheOneYouWant.

Relevant Meme
Code for C
Tutorial is loading...

Author of this problem was FastestFinger.

Relevant Meme
Code for D
Tutorial is loading...

Author of this problem was Ashishgup.

Relevant Meme
Code for E
Tutorial is loading...

Author of this problem was FastestFinger.

Relevant Meme
Code for F
Разбор задач Codeforces Round 646 (Div. 2)
  • Проголосовать: нравится
  • +854
  • Проголосовать: не нравится

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

Auto comment: topic has been updated by TheOneYouWant (previous revision, new revision, compare).

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

like D

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

Never imagined C could be easier than A.

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

Nice problemset, like it. But shitty D statement has spoiled an impression a bit :(

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

fast editorial

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

FastestFinger ==> FastestEditorial

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

I am having trouble deciding what sucks more — this contest or your sense of humor.

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

Relevant Meme for Problem D is too close to heart <3

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

i'm in love with those pictures too :ddd

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

Adding memes to editorial is becoming a trend

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

Missed n==1 case for C. FML -_-

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

Thanks for such a good contest !

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

How is N^2 passing in B, even Reds have written N^2 to solve fast. How they knew it's gonna pass.

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

this was a nice contest and editorial is also very much fast.

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

Problemset was nice.

Here is a simpler solution for Problem A :

let k denote the number odd values in the array.

Answer is "no" if one of the following satisfies :

1) k = 0

2) k = n and x is even

3) x = n and k is even

Why ? (Left to reader)

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

The C meme is hilarious

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

How to solve E when digits aren't necessarily binary?

I accidentally tried to solve this harder variant during the contest because I didn't read that digits are binary (oops...)

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

In problem B, I think simple O(n^2) should pass as length of string is less than 1000. But gave TLE on simple approach. Correct me if I am going wrong.

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

Can someone please explain A's solution? Why does it work? I don't get it.

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

    Umm I will attempt to explain ! For choosing out K elements who sum up to give an Odd Number ! So it is prerequisite that We calculate in handy about how many odd and even integers are there in this array , now if no odd number exists it is clear that sum will never be able to get odd ! Another case is when You Have K as odd and CountOfOdd greater than equal to K you can fit these odd numbers in K and get a result , (For eg if you take 1 3 and 5 and sum up it gives 9 so it should be remembered that Taking ODD count of Odd Numbers and summing up gives and Odd Number , Another case will be when You have Not sufficient odd numbers to complete you K in that scenario you can take 1,3,5.. of the odd numbers you have in your count and can opt for taking other even numbers ,There is a catch for N==K case ! it is explained well in Editorial I think

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

question 1 9 7 11 14 1 6 3 12 3 20 16 how this is YES

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

System tests to problem D might be weak, I hacked my own submission 82140938.

Feel lucky tonight :P.

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

Please, for the love of god, someone tell me what is wrong with the following answer to E: https://mirror.codeforces.com/contest/1363/submission/82145487 I really hope something is wrong so I won't feel I was python-robbed again.

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

That's sad when your 100 lined code was actually checking n%2

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

Who wants to help me with D? https://mirror.codeforces.com/contest/1363/submission/82145477 Looks like I'm writing or reading incorrectly (wrong answer Token "162" doesn't correspond to pattern "!|?" error) but I don't see the mistake.

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

Is it just me or someone else also got deceived by the constraints of Problem C with $$$N$$$ = $$$1000$$$

I spend a lot of time doing dfs or building $$$O(N^2)$$$ solution in the end to realise that except for the degree of $$$x$$$, even all other edges are useless :P

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

If anyone wants a detailed explanation on A https://www.youtube.com/watch?v=0_b4YKuIPeU

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

Press F for everyone who failed the systest in problem D

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

The meme of D is the truest thing I've seen lately. Nice contest!

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

Interesting tutorial i've ever seen. :)

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

...

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

The problem C is very very interested.I was completely off track the solution.Feels like crying after seeing that the solution is such easy.

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

Where am I going wrong for question D:

error: Idleness limit exceeded

code logic: get maximum by querying for 1 to n ans will be maximum for all k except one slot. use binary search for finding the slot number in which maximum belongs query for found slot.

Code link:82134674

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

    Note that not all of the indices need be in a subset. In one of the last loops you print all subsets except one, but since some index might not be in a subset, it could print less indices than indicated (the first number after ?), then block waiting for input.

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

Anybody knows where can we find more problems like A? (Once in a while such A's tend to totally massacre the contest, if possible I would like to train on such kind of problems to save myself from such wreckage.)

There was a similar problem from Dreamoon's contest. Round#631 div 2-A

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

Does the author of problem himself selects the relevant meme, if so FastestFinger you've won this round unanimously.

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

I just want to take a moment and say POOR MEME GAME -_-

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

I didn't understand E after we reset the cost of nodes (from the start of the greedy solution). Thanks in advance if somebody explains it.

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

Video Solution Of Problem C : Solution

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

Can anyone please help me in problem D.? I have the same idea as explained in this tutorial. I'm getting, "wrong output format Expected int32, but "-4260782116" found" in test case 7. My submission: https://mirror.codeforces.com/contest/1363/submission/82151133

Update: No need . I've got my answer from previous comments. Problem was. it is not always true that given set always contains all the indices.

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

https://mirror.codeforces.com/contest/1363/submission/82151479 Can't get rid of Idleness limit exceeded on test 7 ... can someone help?

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

![ ]

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

this is gonna be the most upvoted editorial ever!! XDXD and maybe this cmmnt will be most downvoted ever XD (typical cf community i fkng love it)

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

1 8 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8

For this test case in C question, the answer should be Ashish but according to the editorial it is Ayush. Please correct me if I am making a mistake. Thanks in advance

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

For problem d

Suppose the root node has two children is it possible to shuffle values of two children (do they both belong to the same subtree)

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

For this problem B, I submitted a code1 and it gave Runtime error. Here I have used long long int as the data type for all suitable variables using a 'typedef long long int ll' declaration at top

Now I just changed all the data types to 'int' by changing it to 'typedef int ll' and everything worked fine code2

In some other submission I changed the string declaration to char and again everything worked fine [code3](https://mirror.codeforces.com/contest/1363/submission/82147815)

I am not really able to understand the failure of code1. Please help me out !!!

** For this problem my friend too faced the same issue. ***

Failed code

Passed code — just changed long long int to int

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

Since (some of you) liked the memes, I decided to post two of the others I had prepared, but did not post lest the editorial look messy,

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

One of the best contests in quite a long time and the sweetest statements, and fast editorial! Thanks so much!

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

can anyone please explain to me why this N^2 solution of the problem B is giving TLE on test case 4. My Code

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

Can some one explain to me why in this test case "Ayush" wins not "Ashish" 1363C - Game On Leaves

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

Coolest Editorial Ever!

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

Come on, i thought i would be the first problem setter who splits key idea from complete solution :(. Nice job TheOneYouWant.

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

what does

if(arr[u] < mn)

signify in E's Editorial code ?

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

In Problem D, can't we use binary search to find the index of the max element and then use that fact. Since k<=n, the no. of operations at its worst should be equal in both cases.
What I m getting wrong? Here's my submission: 82156330
Thanks in advance!!

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

Out of all possible errors how did I get memory limit exceeded for D ? :(( 82128649

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

Problem C is a harder (easier?) version of B. Binary Tree. The observations are almost identical in both problems.

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

can someone help me with the recursive dp or memoized approach for Problem B.

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

    Ummmm ! Now that you have mentioned I suppose it can be done using recursion with some clever memoization where recursively create all the strings of the form 1111's followed by 0000's and strings of form 00000'ss followed by 1111's We will create all the strings and check for a minimum ans out of all such possibilities and to add some memoization for any string we can calculate number of mismatches upto some index and later use it for fast computation !

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

    But Yes DP will be overdoing things a single prefix array will suffice to crack this problem !

    Happy Coding :)

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

in c problem if the test case: n=6 x=2 1 2 1 6 2 3 2 4 2 5 then ashis will be winner but n is even . anyone help please

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

    I don't think Ashish is the winner in this case ! in the first chance Ayush will go for 3,4,5 or 6 which are the leaf nodes and subsequently he is playing optimal so if you make any sort of choices from this state You will always Find Ayush having the last laugh!

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

Any clue about test case 37 of Problem D ?

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

https://mirror.codeforces.com/contest/1363/submission/82161309 why fflush(stdout) is not working??

upd: fflush(stdout) will not work if you are using fast con,cout in c++

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

Is there any approach for C involving grundy numbers and/or nim sum? I tried really hard to find someone..

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

    My idea is make the tree rooted from node x and calculate the amount of sons it has for each brach. Since for win the game I have to make the node x leaf, and for that need to eliminate all nodes of each branch first(all except one branch, I mean if there are k branchs, it is enough to eliminate k-1 of them) then the game is reduced to a modified nim game where the goal is reach the state {0 1} and for each turn the player can select one "heap" (amount of sons calculated previosly) and decrease it by 1.But I can't find a winning strategy for that game, please let me know if I am making some mistake..

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

      Solved: I realized that if I consider each heap as a nim heap the grundy number of each one will be 0 if it's even and 1 otherwise (this is because I'm only allowed to take 1 element each turn and 0 is a losing state) then I find the nim sum of the k-1 heaps, if the grundy number of the remain heap is 1 my nim sum change, otherwise nothing happen. So it is enough to find the nim sum of all of them. The special cases are handled seperately. This is equivalent to the approach of the editorial, but using Spargue-Grundy theorem

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

I loved the editorial.What an Explaination!Thank you so much FastestFinger Ashishgup TheOneYouWant. You guys won many hearts today!

Waiting for more Indian Rounds!

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

In Problem D, instead of binary searching the subsets, we can query[1..n] first to get the maximum, then binary search the index of the maximum by querying [1..mid] each time.

In this way, we can get the exact index of the maximum (when there are multiple, the first one).

Then we just check whether a subset contains this index. If so, we query its complement.

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

my logic for b was exactly the same don't know why test case 3 did't pass.

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

[Deleted]

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

Though I couldn't solve much I enjoyed it!

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

82161582

Can anyone tell me why this solution for Problem D is failing for testcase 37 ?

The basic idea behind the solution is that the variable lo is used to store the index of the maximum element; and mx and mn are the highest and the second highest elements of the array respectively.

After the binary search, I use one query to check the subset lo+1,lo+2,....,n-1,n because this subarray may hold the second highest number (This is because in all the previous queries, the mx variable would overshadow the the second highest number if it fell in the lo+1,lo+2,....,n-1,n subarray.)

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

Wow!!

what a nice contest!

thank you so much.

especially an interactive problem on my level after a long time was so good.

I enjoyed it.

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

Nice problems. I enjoyed a lot. Thanks.....

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

Can anyone explain how to solve F?

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

Can someone help me why 82180993 getting RTE on test 9?

My idea is to sort the nodes non-descending by its cost and try to shuffle as many nodes as you can from the lowest-cost node.
I use segment tree and euler tour tree. After every shuffling, I updates every shuffled nodes with lower bound on sets (Maybe this one causes RTE)

I know there are neater implementation using root-to-leaf minimum, I'm just curious why my code gets RTE. Thanks

EDIT: Found it! Segment tree size is not enough. set segtree size to 1,2 mil apparently gives ac, idk why it needs that much for this problem

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

@hey i am just a beginner could u plz help me in editorial of B problem as iam unable to get .plz

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

    I will try to explain it to you ! To make a string free of any sub sequences of '101' and '010' I think you must have deduced that much that the only possible string which will form an answer must of one of the following forms.

    1) A series of 1111's 2) A series of 0000's 3) A series of 1111's followed by a series of 0000's 4) A series of 00000's followed by a series of 1111's

    So The Editorial of B is trying out all Possible such strings and considering the answer as a string with minimum mismatch between the given string as input and string we are considering ! Now Trying out all strings can Give U TLE ! So Using a prefix sum array to store in handy the number of 111's you have till i'th index will help you calculate the ans !! I can help you with the code part if idea is clear to you

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

I'm having very rough times solving C. Since last 3 contests, I've found a D/E that I found easier than C. This time it was E, I could do it in about 20 minutes after contest.

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

Hey guys i am having some trouble debugging my solution to E.I have added a few comments to my code here. my approach involves using dfs and if a node has a cost smaller than all its ancestors, we use this weight and do all changes possible to the subtree(including the node) of this node. Any kind of help will be appreciated. Happy coding :).

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

Hello Codeforces!

Thanks for the great contest FastestFinger Ashishgup TheOneYouWant

I am facing problem in Question D.

My approach is almost the same

1) First I find the maximum among the whole array.

2) Then I keep lo = 1 & hi = n and do queries to find the index between [1, n] which has highest element in the array A.

3) Then I iterate over all the subsets in S to see if it contains the index having the highest element in A. If it contains such an index then I make a query on indexes not in that subset and print that. Else I print the maximum element.

I am getting the wrong answer on test 4.

My code can be seen here:- 82190773

TIA

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

I have a solution for E which is similar to the idea in the editorial but it uses a small trick and without maintaining the parent and instead storing how many unbalanced cases are to be resolved by shuffling in sub-tree of a node. Code

For the case of impossibility if summation of bi != summation of ci, we print -1 otherwise we have a solution. We have a global variable ans which we print if it's possible to reshuffle values to get desired structure. So we maintain a global array 'unbalanced' which stores how many 1s in sub-tree of the node still require shuffling while maintaining a[node] <= a[par] for node != 1 (the root). So for any node let the initial unbalanced amount be c[node] — b[node]. We will see how this comes handy later. Now if we sum unbalanced[v] for all v in children of node with unbalanced[node] we get the number of 1s that cannot be shuffled within the sub-tree rooted at node. Even if it turns out to be negative it is fine as it will get balanced by some other nodes as summation bi = summation ci. Now unbalanced stores the number of 1s in sub-tree of v which cannot be resolved by any shuffles within the tree and the number of shuffles which can be made in the sub-tree is {summation abs(unbalanced[v]) | node is a parent of v + abs(c[node]-b[node]) } — {abs(unbalanced[u])}. We multiply this with a[node] and add it to the global answer variable, as the optimal cost for shuffling can only come from this because a[par] >= a[node] which I maintain by this, if(a[v] > a[node]) a[v] = a[node];

It might seem difficult to understand. A lot a of expressions in this comment would have cleared it even more. I hope someone reads this and finds it useful. :-)

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

Is that unrated?

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

Another solution B: resultant string will be of form s1+s2,where s1="00.." and s2="11.." or s1="11.." and s2="00..".looking at constraints O(n*n) will work .so we can check all strings of these type to find minimum number of changes.

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

I love the way you guys made this editorial. The concept of Key Idea and Detailed Explanation was really good .

»
6 лет назад, скрыть # |
Rev. 4  
Проголосовать: нравится 0 Проголосовать: не нравится
In problem E, if we change this part of code:
for(auto &it:g[u])
	{
		if(it == par)
			continue;
		pair<int, int> p = dfs(it, u, min(mn, arr[u]));
		a.first += p.first;
		a.second += p.second;
	}
To this:
for(auto &it:g[u])
	{
		if(it == par)
			continue;
		a.first += dfs(it, u, min(mn, arr[u])).first;
		a.second += dfs(it, u, min(mn, arr[u])).second;
	}

It dosen't work, why?

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

Good contest. My ego made me stuck on A and still couldn't solve in 5 attempts.I found B and C easier.

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

can anybody explain how to solve problem E i am not getting it as i want to know how to things will work on tree can anybody show tree diagram??

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

    Consider the following graph 4 1 2 2 3 3 4 then subtree of 1 is 2 3 4,subtree of 2 is 3 4 and subtree of 3 is 4 . then you are given some value of b and c . if value of b is 1 and value of c is 0 then you can shuffling between them ,and at the mean time you will consider the cost of the parent which cost is less. suppose you can shuffling node ( 2 , 4 ) or ( 3 , 4 ) .but the cost of 2 is 10 and 3 is 20 . so you will choose 2 as parent . and you will perform dfs and track down the minimum cost . To understand better you can watch this solution : https://mirror.codeforces.com/contest/1363/submission/82224132

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

In the editorial for D, why do we iterate from 0 to mid (inclusive) instead of st to mid (inclusive)?

Code:

		for(int i = 0; i < k; i++)
			if(i == st)
				ans[i] = interact(ask);
			else ans[i] = max_element;

I have something similar but mine is not passing.. . 82227750

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

    The problem encountered in that submission is due to poor handling of multiple test cases — in all cases, the second test case should produce an error.

    There is also a problem with the inverse querying.

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

Please,why I get “Memory limit exceeded” in probem D,82232793

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

Please somebody help me out. I have done problem D using binary search as suggested in editorial but getting error: IDLENESS LIMIT EXCEEDED on test case 7. Link to my submission https://mirror.codeforces.com/contest/1363/submission/82238839 Thanks in advance :)

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

In Subsequence Hate , I got "Wrong answer on pretest 2".

My submission : 82118663

But when I checked the testcase, it said for

10111101000010100

the answer should be 7 flips

but I can make it good by using 4 flips only 1(1)11110(0)0000(0)0(0)00, which is valid

Correct me, if I'm wrong on understanding the problem statement.

Resolved: My mistake! Thanks dorijanlendvaj for correcting.

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

    Your solution says that the answer is 7; the correct answer is 4.

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

    The answer it expects is 4 and your code gives ans as 7 ! I have seen your code and I suppose you are tring to find first occurence of 1 and then making 0's after that as 1 and also doing the same thing for first occurence of 0' this logic will not work !! I suppose you should try to approach the problem with trying all the series possible cleverly and form an answer in O(N) time

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

Can anyone give a rigourous proof for the dp solution for f. What does the dp state define?

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

A new era is arrived and that is EDITORIAL WITH MEMES....

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

https://mirror.codeforces.com/contest/1363/submission/82288453 can anyone tell me why i am getting memory limit exceeded in my code?? i have submitted 10 times not able to figure it out please help??

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

I am getting Idleness limit exceeded on problem D. Can somebody help me? https://mirror.codeforces.com/contest/1363/submission/82288138

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

Can someone explain the editorial solution of 1363F - Rotating Substrings in detail..

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

I have implemented same logic in problem D as explained in editorial still getting wrong answer. Query Function is returning a garbage value. Plz help anyone? Here is my submission id :- https://mirror.codeforces.com/contest/1363/submission/82306483

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

I am a newbie can you help me with code below? Codeforces Round 646 Div-2 1363A-Odd selection what is wrong in my code?

https://mirror.codeforces.com/contest/1363/submission/82093977

Also all suggestions will be welcome :)

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

In Problem D, i am getting WA in case 16, but i cannot figure out why? My Approach : I first got the maximum value of full array, than by binary search find out the position of that maximum value in the array. Than just proceed the k subset. Can anybody look at my code and help me to figure out please, My Code

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

damn!! the editorial is really good!!

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

Could someone please explain me problem E ? I missed something and I really don't get it and it angers me.

Why is last example impossible?

2
109 0 1
205 0 1
1 2

Just take node 1 and switch digits of nodes 1 and 2... Cost : 218.

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

Good follow up for beginners -
In Problem A, count the # of ways of choosing $$$x$$$ numbers so that the sum is odd.

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

What is the purpose of the variable mn in the editorial's solution for E?

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

Can someone please explain how the moves will carry out for this input -

1 5 5 4 5 4 2 3 5 4 1

I presumed -> Ayush takes 1, Ashish takes 2, Ayush takes 4, Ashish takes 5 and wins

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

solution :- https://mirror.codeforces.com/contest/1363/submission/82384349 code for D, getting an absurd error if anyone could help?!

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

    The diagnostics output gives quite a good warning:

    Error: attempt to subscript container with out-of-bounds index 0, but container only holds 0 elements.

    Looking at the code, the reason is quite clear:

    pre.clear();
    for(int i=0;i<k;i++){
        int c;
        cin>>c;
        if(i==0) pre[i] = c;
        else pre[i] = pre[i-1] + c;
        // ...
    }
    

    You likely want to resize the vector before assigning new values to it.

    Also, note that the vectors in s are never cleared.

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

can any one explain 1st problem?

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

    This was my thinking in the contest:

    Look at the array 'a' modulo 2. It will be 1s and 0s.

    Count how many 1s there are — 'numOnes' and how many 0s there are — 'numZeros'. The minimum sum we can create with x elements is lb = max(0, x — numZeros), where we took as many 0s as possible. The maximum sum we can create is ub = min(x, numOnes), where we took as many 1s as possible. Since the entire array is 1s and zeros, we can also create any number in the range [lb, ub].

    Now the sum of the x elements we pick can be odd if and only if the sum of their remainders modulo 2 is odd, that is, when there exists an odd number in the range [lb, ub]. Obviously this odd number will not exist if and only if the range consists of a single even number, that is, lb == ub && lb % 2 == 0.

    My code: https://mirror.codeforces.com/contest/1363/submission/82065526

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

can someone help me on question D? I am getting "Idleness limit exceeded on test 7" though I used cout.flush(). Here is link to my submission : https://mirror.codeforces.com/contest/1363/submission/82422145

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

I came here for the memes

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

82879714 It said,"Wrong answer on test 2."

what is the problem? I don't understand. Please help me.

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

Please add the link of the editorial with the problems.

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

Problem F ( Rotating SubString ) :: Commented Code With Explanation

101216700

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

In Question C what this line means "and remove it together with any edge which has this node as one of its endpoints."

»
3 года назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится
  • I am seeing Tag of Problem as Hint and rather than it being helpful,it is just pointing in wrong direction.It is doing more harm than good.
  • DP tag is default for every question. If you use array to read input then DP tag is being added to question since it is using Memorization.
»
10 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Can someone tell me how we build the graph?

Like, for example, in the first testcase of the first example input, n is 3, and x is 1.

How do we know this isn't the graph?

3

3 1

3 2

Isn't it a win for Ashish?