### TheOneYouWant's blog

By TheOneYouWant, history, 5 months ago,

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.

Author of this problem was Ashishgup.

Relevant Meme
Code for A

Author of this problem was Ashishgup.

Relevant Meme
Code for B

Author of this problem was TheOneYouWant.

Relevant Meme
Code for C

Author of this problem was FastestFinger.

Relevant Meme
Code for D

Author of this problem was Ashishgup.

Relevant Meme
Code for E

Author of this problem was FastestFinger.

Relevant Meme
Code for F

• +854

 » 5 months ago, # |   +1 Auto comment: topic has been updated by TheOneYouWant (previous revision, new revision, compare).
 » 5 months ago, # |   +37 like D
•  » » 5 months ago, # ^ | ← Rev. 2 →   0 I have another idea: because $1000 <2 ^ {10}$, we can perform the $log_2 {k}$ query, and the $i$ query the union of the sets which binary expression of the set number's $i-th$ bit equals to $1$ in the $i$ th query. This can also find the position of the maximum value :-)
•  » » » 5 months ago, # ^ |   +22 Doesn't it take $2\lceil\log_2k\rceil$ queries?I think you may need to query twice for each bit?
•  » » » » 5 months ago, # ^ | ← Rev. 2 →   0 What you said is my initial idea, but it is not really necessary. In fact, this algorithm can pass this question! Maybe it’s because I’m a foreigner, and the English expressions I use are not good enough. You can look at my code and try to understand my method. https://codeforces.com/contest/1363/submission/82139983
•  » » » » » 5 months ago, # ^ |   +8 Now I think I've understood it.Thank you so much.And,orz :-)
•  » » » 5 months ago, # ^ |   +4 What if there are multiple positions with maximum value? Consider: N = 5 and Arr = {10, 10, 10, 10, 10} For bit position 0 (index = 0, 2, 4): Max = 10 For bit position 1 (index = 1, 3): Max = 10 For bit position 2 (index = 4): Max = 10 According to the queries, the index with max value is (111) in binary representation which is 7 and it is out of bound. Correct me if I am wrong.
•  » » » » 5 months ago, # ^ |   0 In fact, the maximum value does exceed the range, but this does not affect the correctness of the algorithm! I did not directly access the position of the maximum value, I just made a judgment on the index of 1~n to determine whether it is equal to the position of the maximum value. You can look at my code and try to understand my method. Sorry for my poor English. https://codeforces.com/contest/1363/submission/82139983
 » 5 months ago, # |   +13
•  » » 5 months ago, # ^ |   0 1 8 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8For 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
•  » » » 5 months ago, # ^ |   +6 no it is Ayush.Ayush will start removing leaf node and Ashish will be the last person to remove third last leaf node after that only two leaf nodes(x and some node v) remain from which Ayush can remove x and he wins.
•  » » » » 5 months ago, # ^ |   +20 you beat me by one minute ;)
•  » » » 5 months ago, # ^ |   +8 Actually Ayush is true, you can see that we will remove node 4,5,6,7,8 in sequence and then it is just like pretest 1, but this time it is Ashish's turn not Ayush's.
•  » » 5 months ago, # ^ |   0 That really wonders me how you think in that much easier way.
•  » » » 5 months ago, # ^ |   +10 I guess experience is helpful
•  » » 5 months ago, # ^ |   0 you're doing a nice job.but what about "video tutorial for D" for the next contest? ;)
 » 5 months ago, # |   +34 Never imagined C could be easier than A.
•  » » 5 months ago, # ^ |   -7 :(
•  » » 5 months ago, # ^ |   +5 Never imagined B and C could both be easier than A.
•  » » » 5 months ago, # ^ |   +1 True bro, I wasted a lot of time in A(almost 45 minutes) rather than going for B or C but still anyhow managed to solve all of the three problems 3 minutes before the contest ended.
•  » » » » 5 months ago, # ^ |   +1 what's the logic behind your B submission??
•  » » » » » 5 months ago, # ^ | ← Rev. 2 →   0 exactly same as the editorialist's concept but if you have seen my code, I used a minimalFilps function directly from geeksforgeeks to get the count of minimum number of flips required to convert the array such that all 1's appear on left side and all 0's appear on right side. Here is the link to that function. Feel free to ask me if anything regarding my approach is not clear to you. Thanks for your time to have a look on my solution.
•  » » » » » » 5 months ago, # ^ |   +1 thanks!!
•  » » » 5 months ago, # ^ |   0 sushant23y what's the logic behind your B submission??
•  » » » » 5 months ago, # ^ |   +3 for every index calculate the cost of making every bit to left of this index to 1 and to right of this to 0. Take the min of these.Then do the same again but for every index calculate the cost of making every bit to left of this index to 0 and to right of this to 1. Take the min of these.Check this answer https://codeforces.com/contest/1363/submission/82186217
•  » » » » » 5 months ago, # ^ |   0 thanks!!
 » 5 months ago, # |   +11 Nice problemset, like it. But shitty D statement has spoiled an impression a bit :(
 » 5 months ago, # | ← Rev. 3 →   0 fast editorial
 » 5 months ago, # |   +4 FastestFinger ==> FastestEditorial
•  » » 5 months ago, # ^ |   +20 Agreed, fast editorials, good problems, nice memes, strong pretests. (At least for me lol) Great contest!
 » 5 months ago, # |   -31 I am having trouble deciding what sucks more — this contest or your sense of humor.
•  » » 5 months ago, # ^ |   +23 I think your comment. XD
 » 5 months ago, # |   +13 Relevant Meme for Problem D is too close to heart <3
 » 5 months ago, # |   +2 i'm in love with those pictures too :ddd
 » 5 months ago, # |   +7 Adding memes to editorial is becoming a trend
 » 5 months ago, # |   +31 Missed n==1 case for C. FML -_-
•  » » 5 months ago, # ^ |   +6 same bro
 » 5 months ago, # |   +1 Thanks for such a good contest !
 » 5 months ago, # |   0 How is N^2 passing in B, even Reds have written N^2 to solve fast. How they knew it's gonna pass.
•  » » 5 months ago, # ^ |   +2 by looking at the constraints
•  » » » 5 months ago, # ^ |   +2 N^2 is 10^8 iterations
•  » » » » 5 months ago, # ^ |   +5 10^8 should pass if you use fast I/O
•  » » 5 months ago, # ^ |   +1 Because scanning memory byte-by-byte is extremely fast. Reds write brute forces if they pass because it takes less time to write.
 » 5 months ago, # |   0 this was a nice contest and editorial is also very much fast.
 » 5 months ago, # | ← 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 = 02) k = n and x is even3) x = n and k is evenWhy ? (Left to reader)
•  » » 5 months ago, # ^ |   +1 I had actually done the same
•  » » 5 months ago, # ^ |   0 i have done the same .....and solution is accepted.... but question says that element should not be consecutive ... and in the solution we have not consider this
•  » » » 5 months ago, # ^ |   0 Question says that elements don't necessarily need to be consecutive but they can be consecutive.
•  » » » » 5 months ago, # ^ |   0 thanks
•  » » 4 months ago, # ^ | ← Rev. 4 →   0  if((even || x&1) && odd && (x <= (even + odd - (odd&1^1)))) printf("YES\n"); else printf("NO\n"); same idea with checking for positive answers
 » 5 months ago, # |   -20 The C meme is hilarious
 » 5 months ago, # |   +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...)
 » 5 months ago, # |   0 Loved to solve these problems!
 » 5 months ago, # |   +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.
•  » » 5 months ago, # ^ |   +1 My O(n^2) solution passed easily.Here is my Solution
•  » » » 5 months ago, # ^ |   0 have done almost the same but got tlesolution
•  » » » » 5 months ago, # ^ | ← Rev. 2 →   +1 I tried to submit in C++17(64) and it ran in 436 ms. (I don't know the reason behind it.)Submission link
•  » » » » » 5 months ago, # ^ |   0 Is it has something to do with c++ 14
•  » » 5 months ago, # ^ |   +7 Numbers of Test cases were 100 ! It would be 10^8 in total ! My Solution failed for O(N*N) approach then I opted for using a prefix sum array !
•  » » » 5 months ago, # ^ | ← Rev. 2 →   +3 Thanks for clarification. I wasted my attempt due to this even after knowing the efficient method :(
•  » » » » 5 months ago, # ^ |   +4 your most welcome
•  » » » 5 months ago, # ^ |   0 This might be the silliest of my doubts...But I've read in comments people saying for O(N*N) it would be 10^8. How come it should be 10^8 when |s|<=1000 and |t|<=100...so in the worst case it should be (1000*100)^2 = 10^10. Please tell me what I'm thinking wrong?
•  » » » » 5 months ago, # ^ |   0 For EACH test case, O(1000*1000). There are 100 testcases = 100 times O(1000*1000) = O(10^8)
•  » » » » 5 months ago, # ^ |   0 O(N*N) for solving each test case. T*N*N in the worst case, therefore, 10^8.
•  » » » » » 5 months ago, # ^ |   0 Got it thanks!!, and one more doubt pls...what is the expected upper bound on number of operations that can be successfully executed in 1 sec without TLE. Until today I thought it was 10^7.
•  » » » » » » 5 months ago, # ^ |   0 The upper bound is indeed 10 ^7 to 10^8 operations under 1 second to my knowledge! Correct me if am wrong !
•  » » » » » » 5 months ago, # ^ |   0 The upper bound is close to 10^9 operations in a second with fast I/O. You can verify by running a for loop of 10^9 operations in custom invocation. But if you have multiple operations in the for loop, I would suggest not running a loop of more than 2*10^8.
•  » » » » » » » 5 months ago, # ^ |   +3 Thanks for the information!!.
 » 5 months ago, # |   0 Can someone please explain A's solution? Why does it work? I don't get it.
•  » » 5 months ago, # ^ |   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
•  » » » 5 months ago, # ^ |   0 Thanks for explaining :)I'm starting to get it. I believe the key lies behind the fact that the sum of x elements is guaranteed to be odd if there are k odd elements in it and k is always odd. So for every i from 1, 3, 5.. x we check whether we have adequate number of even elements i.e. n_eves >= x - i where i is always an odd integer.If such a condition is met, the answer is "YES" else "NO". Alright cool. Will remember this.
•  » » 5 months ago, # ^ |   0 for n elements , let o be the odd numbers and e be the even numbers . clearly , if o =0 then answer is no . now consider 2 cases and their sub-cases .1) x<=o a)x is odd then answer is yes because we can choose all odd numbers . b) x is even , then answer is yes if e>=1 because we will need at least 1 even number to satisfy x as we will choose o-1 odd numbers (even number of odd numbers sum to an even number).2 x>o a) o is odd then ans is yes as we can choose all odd numbers and remaining required even numbers . b) o is even , then ans is yes if (o-1)+e>=x as we will choose o-1 odd numbers and remaining even numbers.
 » 5 months ago, # |   +23
•  » » 5 months ago, # ^ |   0 Great explanations :)
•  » » 5 months ago, # ^ |   0 Hie, can you help me with recursive dp approach for B
 » 5 months ago, # |   0 question 1  9 7 11 14 1 6 3 12 3 20 16  how this is YES
•  » » 5 months ago, # ^ |   +3 11 14 1 6 3 12 20 you can see sum is odd
•  » » 5 months ago, # ^ |   +3 take 11 14 1 6 3 12 20, the sum will be odd
•  » » 5 months ago, # ^ |   +3 You can take 11 14 1 6 3 20 16 which has odd sum 71
 » 5 months ago, # |   +6 System tests to problem D might be weak, I hacked my own submission 82140938.Feel lucky tonight :P.
•  » » 5 months ago, # ^ |   0 Read this : comment by mike
•  » » » 5 months ago, # ^ | ← Rev. 3 →   0 piyush33patel, thanks for the infomation. I submitted to problem D only 2 minutes before the end. When waiting for pretest, I checked my code and found a bug. I thought it would certainly fail system test since it is easy to construct a test against that bug. It is ok for me if the rating change is not final.
•  » » » » 5 months ago, # ^ |   0 Uphacking doesn't affect standings, so you will keep your rating.
 » 5 months ago, # |   0 Please, for the love of god, someone tell me what is wrong with the following answer to E: https://codeforces.com/contest/1363/submission/82145487 I really hope something is wrong so I won't feel I was python-robbed again.
•  » » 5 months ago, # ^ | ← Rev. 2 →   0 You likely hit stack overflow. It's a shame an equivalent C++ solution passes just fine.
•  » » » 5 months ago, # ^ |   0 the same happens with Scala https://codeforces.com/contest/1363/submission/82170122I even tried a tail recursive solution, but that exploded in memory
•  » » 5 months ago, # ^ |   -10 For Python you might be able to set a new stack limit. I'm not too sure if CodeForces allows this but you could do: import sys sys.setrecursionlimit(10**7) This may give an error but it's worth trying. (On a side note, a Java solution with dfs also works fine)
•  » » 5 months ago, # ^ |   0 I did similar thing using JAVA and I am simply applying DFS here, https://codeforces.com/contest/1363/submission/82320024 , but its showing TLE on 9th test case. IT IS SO SAD CODEFORCES.
•  » » » 5 months ago, # ^ |   0 Use Fast IO if you are using JAVA, I am using JAVA for a long time and haven't faced a single issue of TLE if I use Fast IO, My solution :82417618
•  » » » » 5 months ago, # ^ |   0 Thanks, this helped me, but instead of using FastIO, I used buffered reader and PrintWriter and it worked like a magic. Here is my submission for reference if anyone else faces this issue.
•  » » 5 months ago, # ^ | ← Rev. 4 →   0 I ended up finding one solution, and creating one solution.1) At first I searched for a while, and found "bootstrap recursion" that someone posted a while ago. Solution: https://codeforces.com/contest/1363/submission/821654642) I implemented an iterative dfs. That was challenging, because you need to deal with the return values for the "recursive" calls, and also maintain local variables. Unlike a simple dfs, you can't just push all your neighbors onto a stack, but you have to push one, finish with it, somehow get a return value, and then push the next. I kept a counter that shows how many of the node's children visited the node, and when the counter reached len(neighbors), I filled the return variable, and popped it from stack. Maybe it's trivial and this solution is simple, but I looked a while for solutions for this and did not find even one (only a reference to a pdf that didn't work, about this matter). Solution: https://codeforces.com/contest/1363/submission/82215100
 » 5 months ago, # |   +67 That's sad when your 100 lined code was actually checking n%2
 » 5 months ago, # |   0 Who wants to help me with D? https://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.
•  » » 5 months ago, # ^ |   +3 It seems that when asking for the maximum of all indices not in the same subset as the index with the maximum value, you assume the input set was ordered, then use z to iterate through the indices to ignore. If the set containing the index which has the maximum value in the array is not ordered smallest to greatest, extra indices are printed in the query.
•  » » » 5 months ago, # ^ |   +8 Unbelievable stupid. Thank you!
 » 5 months ago, # |   +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
•  » » 5 months ago, # ^ |   0 Sir, I am in the same state as you. I really feel like crying.I am not being able to be patient while solving problems.try for 15 mins to 10 mins,else I feel giving up
 » 5 months ago, # |   0 If anyone wants a detailed explanation on A https://www.youtube.com/watch?v=0_b4YKuIPeU
 » 5 months ago, # |   +6 Press F for everyone who failed the systest in problem D
 » 5 months ago, # |   +4 The meme of D is the truest thing I've seen lately. Nice contest!
 » 5 months ago, # |   0 Interesting tutorial i've ever seen. :)
 » 5 months ago, # | ← Rev. 3 →   0 ...
•  » » 5 months ago, # ^ |   +3 I guess it meant that both of the guys wanted to remove it first(special node). To do so they will make each other to remove unwanted leaf nodes. So they will start from the farthest.
•  » » » 5 months ago, # ^ |   0 Ok understood
 » 5 months ago, # |   +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.
 » 5 months ago, # | ← Rev. 2 →   +3 Where am I going wrong for question D:error: Idleness limit exceededcode 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
•  » » 5 months ago, # ^ |   +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.
•  » » » 5 months ago, # ^ |   +5 Oh I didn't see that coming.I thought every index is part of exactly 1 slot.Thank you. It was my first interactive that I have solved on my own.
 » 5 months ago, # | ← 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
 » 5 months ago, # |   -7 Does the author of problem himself selects the relevant meme, if so FastestFinger you've won this round unanimously.
•  » » 5 months ago, # ^ | ← Rev. 2 →   +16 I made/choose all of them. :) (Although FastestFinger helped with the editorial of F)
•  » » » 5 months ago, # ^ |   +3
 » 5 months ago, # |   -13 I just want to take a moment and say POOR MEME GAME -_-
 » 5 months ago, # |   +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.
 » 5 months ago, # |   0 Video Solution Of Problem C : Solution
 » 5 months ago, # | ← 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://codeforces.com/contest/1363/submission/82151133Update: 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.
•  » » 5 months ago, # ^ |   0 can u please tell me my mistake in problem D,it;s giving a weird error in test case 1 itself.https://codeforces.com/submissions/Lord_Saga
•  » » » 5 months ago, # ^ |   0 When asking for mv, you don't specify how many indices you are going to provide.
•  » » » » 5 months ago, # ^ |   +5 Got AC . I was worried that i might not get any reply but you made my day by helping me out.Thanks sooo much :) <3
•  » » » » 5 months ago, # ^ |   0 Btw how did you put "mv" in the special box? Do you use any software?
•  » » » » » 5 months ago, # ^ |   +1 That's inline code — you can use it from the top bar of the editor (a script-like button) or by wrapping some text in , like mv.
•  » » » » » » 5 months ago, # ^ |   +5 marko312 You are really a good man bro <3I don't know you but I became a fan.
 » 5 months ago, # |   0 https://codeforces.com/contest/1363/submission/82151479 Can't get rid of Idleness limit exceeded on test 7 ... can someone help?
•  » » 5 months ago, # ^ |   0 You don't ever initialize vis, so some garbage / data from a previous test case could affect something down the line.
•  » » » 5 months ago, # ^ |   0 still the same story idleness limit... https://codeforces.com/contest/1363/submission/82161988 i am frustrated now... :(
•  » » » » 5 months ago, # ^ |   +5 What if the index with the maximum value is not in any of the subsets?
•  » » » » » 5 months ago, # ^ | ← Rev. 3 →   +5 Thanks you so much... i can see my mistake now... thanks thanks...
 » 5 months ago, # | ← Rev. 2 →   +28 ![ ]
 » 5 months ago, # | ← 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)
•  » » 5 months ago, # ^ |   0 29 it goes
 » 5 months ago, # |   -6 1 8 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8For 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
•  » » 5 months ago, # ^ |   0 Posting the same qn again and again ain't gonna fetch you the answer. I hope you understand that. Be patient someone will eventually pick up your qn.lllll
•  » » » 5 months ago, # ^ |   0 Extremely sorry about that
•  » » 5 months ago, # ^ |   +14 Remember, node $x$ can be picked up when it's degree is $<2$.The answer should be Ayush, indeed. Let's simulate it.Ayush picks $8$.Ashish picks $7$.Ayush picks $6$.Ashish picks $5$.Ayush picks $4$.Ashish picks $3$.Now, Ayush can pick either $1$ or $2$. He chooses $1$, and wins.
•  » » » 5 months ago, # ^ |   0 Got it!Thanks a lot for the help!!
 » 5 months ago, # |   0 For problem dSuppose the root node has two children is it possible to shuffle values of two children (do they both belong to the same subtree)
•  » » 5 months ago, # ^ |   0 yes it is possible and it is problem E not D
 » 5 months ago, # |   0 The tutorial and the rating updated within 2 hours from the contest, that really impressive.Keep it up codeforces, it's keeps on getting better and better everyday.
 » 5 months ago, # |   +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 topNow I just changed all the data types to 'int' by changing it to 'typedef int ll' and everything worked fine code2In some other submission I changed the string declaration to char and again everything worked fine [code3](https://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 codePassed code — just changed long long int to int
•  » » 5 months ago, # ^ |   0 Because of memory overflow
•  » » » 5 months ago, # ^ |   +3
 » 5 months ago, # |   0 If someone wants to see the solution of B using prefix sum here it is: https://codeforces.com/contest/1363/submission/82153257
 » 5 months ago, # |   +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 Please be assured that is not how we actually felt but only for humour purposes :) Half the credit for this goes to aryanc403 Relevant Meme, Problem D
•  » » 5 months ago, # ^ |   +9 The second one <3
•  » » 5 months ago, # ^ |   0 can u please tell me my mistake in problem D,it;s giving a weird error in test case 1 itself.https://codeforces.com/submissions/Lord_Sagahoping to get a reply.
 » 5 months ago, # |   +4 One of the best contests in quite a long time and the sweetest statements, and fast editorial! Thanks so much!
 » 5 months ago, # | ← 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
•  » » 5 months ago, # ^ | ← Rev. 2 →   0 try to use ss.clear() instead of creating a new vector everytime. check this 82160254
•  » » » 5 months ago, # ^ |   0 Thanks for the reply but I found that even My code got accepted when I submitted it with GNU C++ 14 / GNU c++ 17 (64). but giving TLE with GNU C++ 17 although I don't know the reason
•  » » » » 5 months ago, # ^ |   0 Can you please explain your N*N approach a bit.
•  » » » » » 5 months ago, # ^ |   0 Yeah sure, we have to observe that there are only limited strings (exactly 2*N) that can satisfy given conditions. A string should be such that first i characters are all one and rest are zeros or all first i characters are zeros and rest are ones i varies from 0 to n(size of given string). Then I simply calculated difference of each of the 2*N strings with given string and took the minimum answer
•  » » » » » » 5 months ago, # ^ |   0 It would be propably much faster if you actually do not create the strings in the first loop, but simply act like you would have done in the second loop.It is fairly simple to find if ss[i][j] is 1 or 0.
•  » » » » » » » 5 months ago, # ^ |   0 Yea I know that
 » 5 months ago, # |   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 
•  » » 5 months ago, # ^ | ← Rev. 4 →   +5 Ayush picks node $4$. Now, it is like the first test case, only the roles are reversed. No matter what Ashish picks, he will make node $2$ pickable for Ayush.UPD: I read your question wrong.
•  » » » 5 months ago, # ^ |   0 but it has 2 degree edges
•  » » » 5 months ago, # ^ |   0 why not pick 3 first
•  » » » » 5 months ago, # ^ |   +5 Because they are playing optimally. Both of them would pick the most favorable one each move.It is mentioned in the problem statement: Determine the winner of the game if each player plays optimally.
•  » » » » » 5 months ago, # ^ |   0 thanks i didn't read it
•  » » » » 5 months ago, # ^ |   +5 If he chooses 3 it will lead to 2 being the Leaf Node and in the next chance Ayush will choose it and win so playing optimally he wont choose 3 first
•  » » 5 months ago, # ^ |   0 If Ayush takes node 4, Ashish is forced to take either 1 or 3, both leaving 2 as a leaf node.
•  » » » 5 months ago, # ^ |   0 why not Ayush take node 3 first
•  » » » » 5 months ago, # ^ |   0 Remember, both play optimally. Since taking node 3 would give Ashish the option to take node 2, Ayush won't do that, being able to guarantee a win by taking node 4 first.
•  » » » » » 5 months ago, # ^ |   +5 thanks i didn't read it
 » 5 months ago, # |   +9 Coolest Editorial Ever!
 » 5 months ago, # |   +9 Come on, i thought i would be the first problem setter who splits key idea from complete solution :(. Nice job TheOneYouWant.
 » 5 months ago, # | ← Rev. 3 →   0 what does if(arr[u] < mn) signify in E's Editorial code ?
 » 5 months ago, # | ← 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!!
•  » » 5 months ago, # ^ |   +3 What if the index with the maximum value is not in any of the subsets?
•  » » » 5 months ago, # ^ |   +5 Thanks, got AC with that approach too. I completely forgot that the subsets are not exhaustive and this case may arise.
 » 5 months ago, # |   +1 video Tutorial for A https://www.youtube.com/watch?v=BoO38O2Qnqg
 » 5 months ago, # |   +5 Out of all possible errors how did I get memory limit exceeded for D ? :(( 82128649
 » 5 months ago, # |   0 Problem C is a harder (easier?) version of B. Binary Tree. The observations are almost identical in both problems.
 » 5 months ago, # |   0 can someone help me with the recursive dp or memoized approach for Problem B.
•  » » 5 months ago, # ^ |   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 !
•  » » 5 months ago, # ^ |   0 But Yes DP will be overdoing things a single prefix array will suffice to crack this problem ! Happy Coding :)
 » 5 months ago, # |   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
•  » » 5 months ago, # ^ | ← 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!
 » 5 months ago, # | ← Rev. 5 →   0 Alternate argument for Problem C: Special cases to be handled just as in the editorial. For any non-special case, the tree, 2 moves before the winning move will look like this(assume 1 is the special node for illustration)... 1/ . . . \2 . . . 3Ayush will win the game if currently it's Ashish's turn and vice versa. Now we've to only determine whose chance is it now(2 moves before winning move). We deleted n-3 nodes. If n-3 is even it's Ayush's chance now because he started the game, else it's Ashish's chance. Eg. if n-3 == 6 then game looks like this Ay Ash Ay Ash Ay Ash wherein they remove all other nodes. Note that neither will remove node 2(even if it's removable) during these n-3 moves because the very next move will make node 1 leaf and hence the opponent will win. Summaryif((n-3) % 2 == 0) cout << "Ashish"; else cout << "Ayush";
 » 5 months ago, # |   +1 Any clue about test case 37 of Problem D ?
•  » » 5 months ago, # ^ |   0 Your code seems to fail for the same test case I generated in this comment.
•  » » » 5 months ago, # ^ |   0 Ok thanks :)
 » 5 months ago, # | ← Rev. 2 →   +1 https://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++
 » 5 months ago, # |   0 Is there any approach for C involving grundy numbers and/or nim sum? I tried really hard to find someone..
•  » » 5 months ago, # ^ |   +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..
•  » » » 5 months ago, # ^ |   +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
•  » » » » 5 months ago, # ^ |   +6
 » 5 months ago, # | ← Rev. 2 →   -17 Deleted
 » 5 months ago, # | ← 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!
 » 5 months ago, # |   +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.
•  » » 5 months ago, # ^ | ← Rev. 2 →   0 UPD : Got it!
•  » » 5 months ago, # ^ |   0 Yes. Because $S_i \cap S_j = \emptyset$, there's at most one subset which has index of first maximum element. Except this one, all position's password will be the maximum value. Then ask answer for this one with its complement.
•  » » 5 months ago, # ^ |   0 I did exactly the same but i am getting Idleness limit exceeded. Can you help me? https://codeforces.com/contest/1363/submission/82288138
•  » » » 5 months ago, # ^ | ← Rev. 2 →   0 Your binary search is wrong. You are query [lo..mid] instead of [1..mid].My bad. Querying [lo..mid] is OK.
•  » » » » 5 months ago, # ^ |   0 Thanks for taking the time to see my code. The error was that ind's size was supposed to be n not k.
 » 5 months ago, # |   +1 my logic for b was exactly the same don't know why test case 3 did't pass.
 » 5 months ago, # | ← Rev. 2 →   0 what will be output for ques 1-12 14 15 ,n and x both are 3
 » 5 months ago, # | ← Rev. 6 →   +1 [Deleted]
 » 5 months ago, # |   +4 Though I couldn't solve much I enjoyed it!
 » 5 months ago, # |   0 I solved B using Bitsets. U can simply take the XOR product of every possible string and then do the popcount . The minimum popcount will the answer.
 » 5 months ago, # |   +1 82161582Can 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.)
•  » » 5 months ago, # ^ | ← Rev. 3 →   +1 Is the second highest element always the one which is used for the subset which contains the maximum index?Here is a small failing test case: k = 1 n = 3 A = [3, 1, 2] S_1 = {1, 3} Correct: [1] Yours: [2] 
•  » » » 5 months ago, # ^ | ← Rev. 2 →   +5 I get it now. Thanks for your help!UPD : Here is the link to the rectified solution : 82194067
 » 5 months ago, # |   +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.
 » 5 months ago, # |   +13 Nice problems. I enjoyed a lot. Thanks.....
 » 5 months ago, # | ← Rev. 2 →   0 Can anyone explain how to solve F?
•  » » 5 months ago, # ^ |   0 Check out the Problem — Shifts.
•  » » » 4 months ago, # ^ |   0 cant we do the same in O(n) , we pick the charcter everytime if we do not have it and insert it if we do have it. (just make a frequency count for that). Any counter example.
 » 5 months ago, # | ← 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
 » 5 months ago, # |   0 @hey i am just a beginner could u plz help me in editorial of B problem as iam unable to get .plz
•  » » 5 months ago, # ^ |   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'sSo 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
•  » » » 5 months ago, # ^ |   0 Thnx a lot...bro...thnx.....
•  » » » » 5 months ago, # ^ |   0 Happy Coding :)
 » 5 months ago, # | ← Rev. 2 →   0 Who else other than me noted that there is no use of adjacency list(vector g[N]) declared in the editorial solution for representing the tree structure as we are only concerned with the degrees of all nodes?
 » 5 months ago, # |   0 In the tutorial of B, author said we have to index from 1. But why?
 » 5 months ago, # |   +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.
 » 5 months ago, # |   +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 :).
 » 5 months ago, # |   +14 Hello Codeforces!Thanks for the great contest FastestFinger Ashishgup TheOneYouWantI am facing problem in Question D.My approach is almost the same1) 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:- 82190773TIA
•  » » 5 months ago, # ^ |   +7 After guessing the answer you are not reading the string "Correct" or "Incorrect". Just fix that and your code is good to go!
•  » » » 5 months ago, # ^ |   +8 Oh! I completely missed thatThanks a lot man for taking out your time.
•  » » 5 months ago, # ^ |   +7 Note that it fails on the first test set with multiple test cases. There was a notice after the sample: Do not forget to read the string "Correct" / "Incorrect" after guessing the password.
•  » » » 5 months ago, # ^ |   +8 Oh! I completely missed thatThanks a lot man for taking out your time.
 » 5 months ago, # |   0 Can someone provide a precisely explained video editorial for problem F(Rotating Substrings) ? Thanks in advance!!
 » 5 months ago, # | ← Rev. 2 →   0 There is my solution uses prefix sum for 1363B - Subsequence Hate : 82192228Task B would be more interesting if the O(n^2) solutions didn't pass
 » 5 months ago, # | ← 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. CodeFor 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. :-)
 » 5 months ago, # |   0 Is that unrated?
•  » » 5 months ago, # ^ |   0 No I saw a comment made by MikeMirzayanov where he mentioned that rating changes are happening for the time being and will be updated after a thorough Plagiarism Check !
•  » » » 5 months ago, # ^ |   0 have a look Comment
 » 5 months ago, # | ← 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.
 » 5 months ago, # | ← Rev. 2 →   +8 I love the way you guys made this editorial. The concept of Key Idea and Detailed Explanation was really good .
 » 5 months ago, # | ← Rev. 4 →   0 In problem E, if we change this part of code: for(auto &it:g[u]) { if(it == par) continue; pair 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?
•  » » 5 months ago, # ^ |   +3 Because dfs is not a pure function. If you call dfs twice, it will add to cost twice and cost will be wrong.
 » 5 months ago, # | ← 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.
 » 5 months ago, # |   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??
•  » » 5 months ago, # ^ |   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://codeforces.com/contest/1363/submission/82224132
•  » » » 5 months ago, # ^ |   0 i havenot done graph till now...i have done trees and after seeing this i thought it can be done by trees and i was troubling which type of implimentation of tree is this is it bfs of graph implimentation?? i should red graph first then try this question?? any suggestions welcome...
 » 5 months ago, # | ← 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
•  » » 5 months ago, # ^ |   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.
 » 5 months ago, # |   0 How would you solve E if the order of the operations was also asked in the question ?
 » 5 months ago, # |   0 Please，why I get “Memory limit exceeded” in probem D,82232793
•  » » 5 months ago, # ^ |   0 One large problem I see is the case when lab is left as -1 — in that case, too many numbers get added to ANS and likely corrupt the querying for the next test case. Since no error checking is done, that could leave some variables with an undefined value, possibly later causing a huge loop.
•  » » » 5 months ago, # ^ |   +5 I see.Thank you.
 » 5 months ago, # |   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://codeforces.com/contest/1363/submission/82238839 Thanks in advance :)
•  » » 5 months ago, # ^ |   0 No need to put your brain on it. I got my silly mistake i was doing. Sorry for asking such silly questions :(
 » 5 months ago, # | ← Rev. 2 →   0 In Subsequence Hate , I got "Wrong answer on pretest 2".My submission : 82118663But when I checked the testcase, it said for10111101000010100the answer should be 7 flipsbut I can make it good by using 4 flips only 1(1)11110(0)0000(0)0(0)00, which is validCorrect me, if I'm wrong on understanding the problem statement.Resolved: My mistake! Thanks dorijanlendvaj for correcting.
•  » » 5 months ago, # ^ |   +8 Your solution says that the answer is 7; the correct answer is 4.
•  » » » 5 months ago, # ^ |   0 Oh, now I understand. Thank You.
•  » » 5 months ago, # ^ | ← 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
 » 5 months ago, # |   +6 Can anyone give a rigourous proof for the dp solution for f. What does the dp state define?
•  » » 5 months ago, # ^ |   +3 Can't understand what it means for s[1,i] = t[1,j].
•  » » 5 months ago, # ^ | ← Rev. 2 →   0 The reason I'm doubting the solution is that the following version of the problem: where instead of right rotations, we swap the elements, is NP-hard. See this : https://stackoverflow.com/questions/18292202/finding-the-minimum-number-of-swaps-to-convert-one-string-to-another-where-the
•  » » » 5 months ago, # ^ |   0 Yes,I think it's a NP-hard problem, but I'm not sure they are same.Need some help...
•  » » » » 5 months ago, # ^ |   +1 Someone posted that problem F is actually same as this https://codeforces.com/gym/101438 problem, and the editorial of that contest provides a much better explanation in terms of LCS, which is not NP-Hard.
•  » » » » » 5 months ago, # ^ |   0 Thanks, that solution was more easy to understand.
•  » » » » » 5 months ago, # ^ |   +3 I can't find the editorial of this contest,the page just include the statement of the problem, but I have seen the problem "shifts" is same as this problem.
•  » » » » » » 5 months ago, # ^ |   +1
•  » » » » » » » 5 months ago, # ^ |   0 Thank you, very nice.
 » 5 months ago, # |   +1 A new era is arrived and that is EDITORIAL WITH MEMES....
 » 5 months ago, # |   0 https://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??
•  » » 5 months ago, # ^ |   0 Your code produces a wrong answer on some test cases. However, since you don't check for the string being "Incorrect", the code attempts to read more values, leaving some variables (especially importantly k) in an undefined state.
•  » » » 5 months ago, # ^ |   0 Can you guide me how to fix it?? It's my first interactive problem...
•  » » » » 5 months ago, # ^ |   0 First, please do check for "Incorrect" — this should give you the correct verdict and allow you to better analyze what went wrong.For the underlying problem, I can provide a (hopefully) failing test case: n = 6 k = 2 A = [3, 1, 2, 3, 1, 2] S_1 = {1, 3, 6} S_2 = {2} Correct: [3, 3] Yours (expected): [1, 3] 
•  » » » » » 5 months ago, # ^ |   0 So in my while loop I should make a if condition if the input string is correct then I will continue loop and if it's incorrect I should return 0?? In this way it will work or different syntax I should prefer for this??
•  » » » » » » 5 months ago, # ^ |   0 Yes, return 0; or exit(0); should work fine for exiting if the string read in is "Incorrect".
•  » » » » » » » 5 months ago, # ^ |   +5 Ohk thanks for your time....
•  » » » 5 months ago, # ^ |   0 Can you also help me? https://codeforces.com/contest/1363/submission/82288138
•  » » » » 5 months ago, # ^ |   +6 Honestly, I spent about an hour looking at this code previously — it behaves just like mine and seems to work on the same principle, but I can't find anything that should be wrong. I even tried a few tests against it on my machine.My next line of action would be to create a problem host (providing the problem / interaction), then generate (small) random test cases to see whether an error can be found to analyse what goes wrong.
•  » » » » » 5 months ago, # ^ |   +11 I will do this. Thank you so much for your time and help
•  » » » » » » 5 months ago, # ^ |   +6 OK — I took yet another look at this, and I'm pretty sure I noticed the error at last: vector ind(k + 5); for (auto s : subs[i]) ind[s] = true; ind could be accessed with values up to $n$, but $k \leq n$, so this could go out of range, causing all sorts of problems.
•  » » » » » » » 5 months ago, # ^ |   +5 Silly mistake as always !! Thank you so much i was really struggling and couldn't find the error. much appreciated.
 » 5 months ago, # |   +5 I am getting Idleness limit exceeded on problem D. Can somebody help me? https://codeforces.com/contest/1363/submission/82288138
 » 5 months ago, # |   +3 Can someone explain the editorial solution of 1363F - Rotating Substrings in detail..
•  » » 5 months ago, # ^ |   +3 I'd like to hear another explanation too because I'm also confused about this solution
•  » » » 5 months ago, # ^ |   0 If someone could atleast add comments in the code, so it is more understandable?
 » 5 months ago, # | ← 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://codeforces.com/contest/1363/submission/82306483
•  » » 5 months ago, # ^ |   0 You're trying to query in the middle of printing the password.
•  » » » 5 months ago, # ^ |   0 Now I have removed query while printing password but still I am getting garbage value in query thats why it is printing garbage value in answer when i tried in custom input. Sir plz help, this is first time when I am doing a Interactive problem. https://codeforces.com/contest/1363/submission/82337085
•  » » » » 5 months ago, # ^ |   0 You're getting a garbage value since the testing program closed its input, but the code is stuck in a loop trying to get more values. Note my other comment.
•  » » » » » 5 months ago, # ^ |   0 Sir , now I removed the infinite loop case but still it is giving wrong answer. Plz help sir https://codeforces.com/contest/1363/submission/82339279
•  » » » » » » 5 months ago, # ^ |   0 Now, you query the maximum of the set that contains the maximum element in the array, using that value for the position where elements from that set should be ignored.
•  » » » » » » » 5 months ago, # ^ |   0 I have done this but still its giving me wrong answer :-( Please help sir. https://codeforces.com/contest/1363/submission/82363733
•  » » » » » » » » 5 months ago, # ^ | ← Rev. 2 →   0 Interestingly enough, the first test is an edge case for your program — what happens when the greatest element is in the last set (so only the start = mid + 1; branch gets run)?
•  » » » » » » » » » 5 months ago, # ^ |   0 Sir, now i took care of that condition also but now it is giving wrong answer on test case 14 https://codeforces.com/contest/1363/submission/82369145
•  » » » » » » » » » 5 months ago, # ^ | ← Rev. 2 →   0 The problem now is that you're making up to 11 queries to find the correct set, one to find the maximum value and another one to find the maximum outside the set which has the index corresponding to the largest value.You need to get rid of a query somewhere, possibly changing your approach.The second-to-last paragraph of the explanation mostly addresses this problem.
•  » » » » » » » » » 5 months ago, # ^ |   0 Sir, but in question maximum queries allowed are 12?
•  » » » » » » » » » 5 months ago, # ^ |   0 Yes, however your code might make up to 13 queries, since it could make up to 11 queries in the binary search.
•  » » » » » » » » » 5 months ago, # ^ |   0 Sir, when i was seeing the editorial code, he didn't included the case if there is no set which have maximum element. As it is not necessary that all the indexes would get covered in k subsets given. I am also looking for that case that is taking one extra query for my code?
•  » » » » » » » » » 5 months ago, # ^ |   +5 Ohh, I got my solution accepted:-).Thank you very much for your time , without you it was not possible for me.
•  » » 5 months ago, # ^ |   0 Also, the actual issue currently causing the first test to fail — your binary search gets stuck in an infinite loop if the greatest element is inside one of the subsets.
•  » » » 5 months ago, # ^ |   0 Sir , I am not able to figure out how binary search is oing in infinite loop as i am always updating start and end in each iteration , sir plz explain https://codeforces.com/contest/1363/submission/82337085
•  » » » » 5 months ago, # ^ | ← Rev. 2 →   0 What would happen if start and end were equal inside the loop (and the element with the maximum value is inside the set corresponding to start/end)?
 » 5 months ago, # | ← 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://codeforces.com/contest/1363/submission/82093977Also all suggestions will be welcome :)
•  » » 5 months ago, # ^ |   0 Please, instead of pasting your code in the comment, provide a link to your submission — it reduces the size of the comment and makes the code more readable.82093977
•  » » » 5 months ago, # ^ |   0
•  » » 5 months ago, # ^ |   0 You have access to the test that failed, and it is quite well readable — you can step through your code logically to see where the fault occurs.In particular, note this branch of the main logic: `if(o>n){ // ... } else{ if(o%2!=0){ cout<<"Yes"<
•  » » » 5 months ago, # ^ |   +5 Yes I got it
 » 5 months ago, # |   0 Hello everyone. I tried using a DP based approach for problem A, but encountered wrong answer for the 3rd pretest. Here is the code: https://ide.codingblocks.com/s/248211Please look at it if anyone can help. Thank you
•  » » 5 months ago, # ^ |   0 Consider this test case15 43 3 3 2 2Expected : Yes (3+3+3+2=11)Your's output : No
•  » » » 5 months ago, # ^ |   0 Thanks man. Got the error.
 » 5 months ago, # |   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
•  » » 5 months ago, # ^ |   0 marko312 at first sorry for mentioning you, i saw you did reply to many comments, can you help me pls!