Comments

I will add to the intuition of why in the first place pick p, which is highest power of 2 less than or equal to k

think in terms of msb's, suppose you have some element which needs to be moved out of its msb position to some lower msb position(to be sorted), then analyze this situation and see what must be the lower bound of k, you will find out the power of 2.

On AmirrzwM → Codeforces Global Round 31, 10 months ago
0
edge case
1
28 2
ans 15 19 
(xor 28 sum 34)

for k = even case

0,n,n,n.. (our initial intuitive solution, which is wrong)

claim:instead of removing set bits from one n its optimal to remove from multiple different n's

in general when bit is 0 in n that means we could use 1's in their position(as xor of them is still 0, as our solution looks like ,,n,n,,) but that could increase the current ai value greater than n if we add more 1's .

so in our first solution

we say 0 n n n instead of removing all bits from first position, we can distribute the 1's removal from different n's, so that the value of n decreases, hence we can use our claim, here to add those extra 1's

implementation is tricky, which i couldn't :(

On wuhudsm → [Plan] Rewrite of Some Editorial, 21 month(s) ago
0

D. Gifts Order
E. Kevin and And
Can you rewrite for these two problems?
Thanks in advance!

Method which worked for me

For someone who need a small hack test case for E

Test case
On physical23 → Weird code, 3 years ago
0

I asked it to replace the defines in the code itself.

Spoiler
On physical23 → Weird code, 3 years ago
0
Click me

If you go right, you always have the chance to go down.There by you can have minimum among those both

In problem c, doesn't the phone lose charge at 0 moment and also will the phone lose charge after it sends a message or before?

could someone explain?

Does anyone have a formal proof for this?

For Problem D

How Δi,j is found over there in editorial? Is there a simpler way?

I did this in the below given way

Found the pattern of how reversing changes the path(about what lines the pattern is reflected) and accordingly what distance each point is moving with respect to reflections, there by finding the Δi,j.

Thanks for the comment

Thanks for mentioning,i was not able to understand why i got tle on pretest 5.

Spoiler

I found a interesting solution for problem B in O(number of fibonacci numbers under n)

        vector<double>fib(35);
        fib[1]=1;
        for(int i = 2;i < 32;i++){
	  fib[i]=fib[i-1]+fib[i-2];
        }
	int n,k;
	cin >> n >> k;
	if(k>30)cout << 0 << nl;
	else{
	    if(k%2==0){
		cout << floor((fib[k-1]*n)/fib[k])-ceil(((fib[k-2]*n)/fib[k-1]))+1 << nl;
	    }
            else{
		cout << floor(((fib[k-2]*n)/fib[k-1]))-ceil((fib[k-1]*n)/fib[k])+1 << nl;
	    }
	}

Can anyone explain the problem D solution?

On GerrySup22 → Geany Snippets Conf, 3 years ago
0

https://github.com/geany/geany/issues/2481 Checkout this link,for further solution

‎ nice contest