Comments

Will you please explain more what you are doing in remaining cases(a>1mil) part? I am unable to understand only by watching your code.

Actually no. Here, you are passing by value a 2D vector which is taking O(N) time for each function calling where N = size of vector. you can declare the vector globally or use pass by reference.

+19

Problem D:

Binary Search: Bro.

Interactive Problem: Yea, bro.

Binary Search: Close your eyes, bro.

Interactive Problem: Ok, bro.

Binary Search: What do you see, bro?

Interactive Problem: I see you, bro.

Binary Search: Broo!!

Interactive Problem: Bro.

That's what I do when I do not understand editorial. I usually do them in given order.

  1. Read the editorial for sufficient amount of time.
  2. Detect the part which I am unable to understand.
  3. Learn the topic if the problem require any.
  4. Search the comment section for better understanding or commenting about the part which I am not getting.
  5. Direct messaging anyone from the friend list who have solved the problem.

Hope that help you.

Can you please share your code? It will be very helpful for me.

I solved E with Sparse table and Binary Search. Kind of overkilled the problem. Code

On OmarNabill → Dynamic Programming, 4 years ago
0

Thank you. The Collection is very good and covers easy to medium level. There is a small typo, It will be Matrix Chain Multiplication instead of Matrix Change Multiplication.

Can you please explain how the influence of n(previous) timestep can be removed?

Your solution is very simple and beautiful

STL set is implemented by binary search tree. That's why you can not subtract the iterators to find the position. You can use Policy Base Data structures or Ordered set for that. Link

I was thinking what if Problem G asked to find Maximum bitwise OR. I came up with an approach for it and want to know is it right or wrong.

The approach is I will always try to make high bits as large as possible. I will iterate from MSB to LSB and for i'th bit position try to take the edge which has 1 at i'th position. If multiple edges satisfies this condition take the edge for which total OR value will be maximum.

code

Since the number of impostors k and crewmates n−k satisfy k>n/3 and n−k>n/3, there must be one pair of adjacent queries that are different.

Can someone please provide a proof of this line from the editorial of problem D1?

I don't have any formal proof. Hope it will help

Let's say XOR of N numbers is zero. If I replace any one number with an other number XOR will change. For example,

A = {1, 2, 4, 7} XOR of A = 0. I can not change value of any one position so that XOR of A becomes 0. I need at least 2 value for that.

My solution is based on a fact that, If N is odd, player making first move always wins. I am going to prove that later and for now let us assume that it is true.

If N is even and XOR of all elements(let, X) is exist in the array, then I can win in my first move by removing the element which is equal to X(arr[i] = X) and game ends. Otherwise, I have to remove an element but the game continues and the game becomes where (N — 1)(which is of course odd) element exists and other player makes the first moves and so the other player wins.

Ok. Now let's prove, If N is odd, player making first move always wins.[Reminder: All elements are distinct]

Let's assume I started the game by making the first move and after some moves the other player got a move where removing one element makes XOR of remaining elements 0. If that happens I always could swap my previously taken element with any one of the currently remaining element which would make remaining XOR not-zero because all elements are distinct.

This process continues until the array is empty. That makes player with first move always win.

I think the time complexity of problem B should be O(n + k^2) instead of O(k^2). Please correct me if I am wrong

May be programmers visualize the roots instead of the brunches of a tree.

oh. I got it now. Thank you very much

The second paragraph of editorial of problem D it's written, "It's never optimal to delete a character that's different from both adjacent characters". I think it will be " always " instead of " never ".

Can you please explain why median is giving optimal minimal?

https://codeforces.me/contest/1418/submission/93095427

Why my greedy approach is wrong for the problem C? Please give me a case that fail the solution. Thank you.

https://codeforces.me/contest/1418/submission/93095427

Why my greedy approach is wrong for the problem C? Please give me a case that fail the solution. Thank you.

Thanks for sharing this. I thought I stuck at a point too. Now, I understood . I need to work harder.

Can you explain the process a bit more?

On Heisenberg_71 → A Lightoj Problem, 7 years ago
+1

thank you for explaining so nicely

I did not quite understood the editorial but I understood your solving process. Thank you for writing the steps so easily :)