Comments

I checked it on a debugger and i=59 is where it overflowed. Also the same code where I substituted (1ll<<i) to poweroftwo(i) gave me an AC, weird behaviour

Yep, I've used 1ll in my wrong submission

My submission to E 242474581. I got long long overflow when I had (1ll<<i) for calculating power of 2s (Specifically at i=59). However, it did not overflow when I calculated poweroftwos by arithmetic (as in submission, the dp array).

Any suggestions why there was an overflow for (1<<i) case? 242470568

On MikeMirzayanov → Please, read this, 3 years ago
0

My deepest condolences and may she rest in peace.

Check the editorial, this question has been answered a million times here.

https://codeforces.me/blog/entry/62393

You need max primality, so maximum no of subarrays with mex as prime. Which prime numbers are easiest to get in an mex? It's 2 and 3. But to get to 2 (or 3) as MEX you need 1 in the subarray as well. If you think about it, an element can affect the maximum subarrays if its in the middle of the array. At the ends of an array, you have n subarrays you can construct using the first (or last) element of an array. However, this number goes up as we go towards the middle and maximises at the centre. Hence, you take 1 as the middle element. Now you need to make sure 2 and 3 together are included in the least number of subarrays (since MEX will then come out as 4, which is not a prime). How do you do that? By taking them as the first and last element in the array.

1846-C - Rudolf and the Another Competition

Any idea why my submission gets a TLE here. Time complexity is O(n*mlogm). 212937677

Spoiler

Can someone help me in this interactive problem, couldn't figure out why I'm getting a TLE. https://codeforces.me/gym/101021/problem/1

My submisision: 212177668

Spoiler

Okay, thanks!

Can someone tell me why my code was giving TLE for 1843D - Apple Tree. All I did was globally define the graph and cnt array similar to the tutorial solution and it worked then.

This is my initial submission: 210536302. This is the final accepted submission: 210538893

0

You're supposed to ask the same questions to all students, so if you ask questions 2,3,4,5.

Student 1 gets a score -4

Student 2,3 get a score of -2.

Hence difference is 2 in this case.

Thanks,I interchanged n and m I'm so dumb

Could someone tell why I'm getting "wrong output format illegal query (test case 1)" in this code?

https://codeforces.me/contest/1797/submission/201367288

0

19th token in second test case. Look at the 19th test case