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

Автор sourabh_jangid, история, 4 года назад, По-английски

You are given three numbers as input $$$A$$$, $$$B$$$, $$$K$$$.
Perform the given below steps K times:-
if $$$A$$$ <= $$$B$$$ then
$$$B$$$ = $$$B$$$ $$$-$$$ $$$A$$$
$$$A$$$ = $$$A$$$ $$$+$$$ $$$A$$$
else
$$$A$$$ = $$$A$$$ $$$-$$$ $$$B$$$
$$$B$$$ = $$$B$$$ $$$+$$$ $$$B$$$

After K steps output the values of $$$A$$$ and $$$B$$$.
$$$0$$$ $$$\leq$$$ $$$A$$$, $$$B$$$ $$$\leq$$$ $$$10 ^ {9}$$$
$$$1$$$ $$$\leq$$$ $$$K$$$ $$$\leq$$$ $$$10 ^ {10}$$$.
If someone can give some hints it will be helpful.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +13
  • Проголосовать: не нравится

Автор sourabh_jangid, история, 4 года назад, По-английски

I encountered this problem in a contest, I was not able to solve it during the contest.
The problem is as follows:-
You are given an array $$$A$$$ where $$$A[i]$$$ is either $$$0$$$ or $$$1$$$ for $$$\forall$$$ $$$i$$$ $$$\leq$$$ $$$n$$$ $$$and$$$ $$$i$$$ $$$\geq$$$ $$$1$$$.
There is an array $$$P$$$ defined as follows:-
If $$$A[i] = 0$$$ then $$$,$$$ $$$P[i] = 0$$$.
If $$$A[i] = 1$$$ then $$$,$$$ $$$P[i] = A[i] + P[i - 1]$$$ $$$,$$$ for $$$\forall$$$ $$$i$$$ $$$\leq$$$ $$$n$$$ $$$and$$$ $$$i$$$ $$$\geq$$$ $$$1$$$.
Now you are given Q queries of two types:-
$$$1$$$ $$$L$$$ $$$R$$$ $$$,$$$ Invert the array $$$A$$$ from $$$L$$$ to $$$R$$$ i.e $$$($$$ If $$$A[i] = 1$$$, then make $$$A[i] = 0$$$ and vice versa $$$)$$$.
$$$2$$$ $$$L$$$ $$$R$$$ $$$,$$$ Output the sum of the array $$$P$$$ from index $$$L$$$ to $$$R$$$.
Note in the query of type 1, the array $$$P$$$ will also change accordingly. And assume $$$P[0] = 0$$$.
$$$1$$$ $$$\leq$$$ $$$N, Q$$$ $$$\leq$$$ $$$200000$$$
It will be helpful if someone can give some ideas.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +4
  • Проголосовать: не нравится

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

I was solving 691E - Xor-последовательности, and in the problem asked to find number of ones in binary representation of a number, I was using C++ STL __builtin_popcount() function to find Number of ones, but when I submitted I got wrong answer verdict, and then I wrote my own function to count Number of ones and then my solution passed. Can anyone explain to me why this is happening? My AC 69283580 code and WA 69283537 code.

Полный текст и комментарии »

  • Проголосовать: нравится
  • -8
  • Проголосовать: не нравится

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

I am trying to solve 611D - New Year and Ancient Prophecy, I wrote 60357814 this solution. I think the Time Complexity of my solution is $$$O(n ^ 2\log{}n)$$$ but I am getting Time Limit Exceeded verdict. I want to know is my Time Complexity analysis is wrong because I saw many $$$O(n ^ 2\log{}n)$$$ solutions are accepted(like 15127310) but not mine.

Полный текст и комментарии »

  • Проголосовать: нравится
  • -2
  • Проголосовать: не нравится

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

I was trying to solve this problem (56E - Domino Principle). I am stuck on Test Case 30.(Link to my submission 58845497). I tried for hours but not been able to find my mistake. My algorithm is same as the editorial given, but it is giving wrong answer verdict on test case 30. Please help me in debugging the code, and also share some debugging technique, what you use during a contest.

Полный текст и комментарии »

  • Проголосовать: нравится
  • -16
  • Проголосовать: не нравится