levi.ackerman1732's blog

By levi.ackerman1732, history, 3 years ago, In English

Question:1549D - У чисел есть друзья My Solution:124753951

My implementation: get the absolute values of differences between two neighbouring cells and then implement the sparse table to get the queries faster. Now using sliding window technique find the max length of window.

Context: I have pretty much tried to implement the solution given in the editorial. Any insight is highly helpful. Thanks.

Full text and comments »

  • Vote: I like it
  • +20
  • Vote: I do not like it

By levi.ackerman1732, history, 4 years ago, In English

Problem: 1272D - Remove One Element

My Solution:108781615

Hello all,

My idea: if two elements are in strictly increasing order(i.e a[I] < a[I+1] ) dp[I+1] = dp[I] + 1

else check if a[I-1] < a[I+1] then dp[I+1] = dp[I-1] + 1

I am not sure where this is going wrong. Any help is appreciated. Thanks for your time.

Full text and comments »

By levi.ackerman1732, history, 4 years ago, In English

Question : 787B - Not Afraid My solution : 99205991

My thought process:

We have to make sure that in every group at least one pair of Ricky & Morty of same Universe are present to prevent the destruction.

My Idea:

insert all the absolute value of members in each group to both a Set & a Vector. If the size of both of them are equal in any group would mean a possibility of destruction ("Yes") else No.

My apologies in advance if I am missing something obvious. Thank you for your time.

Full text and comments »

By levi.ackerman1732, history, 5 years ago, In English

Hello all,

1301B - Motarack's Birthday

I have read the editorial and implemented the same. My code fails in some hidden test case. If any of you could provide some insight as to what I am doing wrong I would be grateful.

My submission: 71058284

I am extremely sorry if I am asking something that is fairly obvious. Thank you for your time.

Full text and comments »

By levi.ackerman1732, history, 5 years ago, In English

Hello all

1201A - Important Exam

My solution, was to store the number of responses(among A,B,C,D,E) for each question and choose the maximum among them and multiply with the marks awarded. I am getting a Runtime error. I am not able to figure out why.

The part of code where it's failing is:

s is string, j is the question number

	temp = (int)(s[j]-'A');

	v[j][temp]++;

I have encountered this problem quite a few times, but have avoided every time somehow. Please do let me know what is wrong with this.

My solution: 70953260

I am extremely sorry if I am asking something that is fairly obvious. Thank you for your time.

Full text and comments »

  • Vote: I like it
  • +13
  • Vote: I do not like it

By levi.ackerman1732, history, 5 years ago, In English

893C - Слух

Hello all

I am trying to solve this question. I came up with a certain procedure, which to me seems right. Let me know if you find a mistake in it. Thanks.

My approach: I have assumed that I am starting from Node 0. I have joined paths from this node to all the other nodes with the given cost(input). For the neighbouring nodes input I have stored such that they do not have any cost to traverse between them, and I have also stored them in a separate vector(say v1) to use them later.

I have used Dijkstra's Algorithm to find the Shortest path from Node 0 to all the other nodes.

Now using v1 I have maintained an additional variable sum to all the additional distances that I need not cover.

I have then added the shortest distances that I found using Dijkstra and subtracted the sum of additional distances.

It works fine for most cases but fails at test case 11. The logic to me seems infallible. Help me with that.

I am extremely sorry If I am missing that is something fairly obvious.

69879696

Full text and comments »

By levi.ackerman1732, history, 5 years ago, In English

230B - T-primes

Hello all,

I am a bit new to this online coding platform hence I am sorry if I am asking anything that is fairly obvious. Getting to the solution of the question: If a number has to be T-Prime, it has to be a perfect square of a prime number.

My algo: 1)check if the number is a perfect square. 2)If it is a perfect square check if the square root is a prime number.

Problem I am facing: My code is working fine for many test cases, but failing at test case 16 with an error(wrong answer 28561st lines differ — expected: 'NO', found: 'YES') The input for 28561th line is 28561(169*169). In my system it is showing "NO" (not a t prime) which is correct.

I don't know where it went wrong. Any help is appreciated. Thank you.

My submission

Full text and comments »

  • Vote: I like it
  • +29
  • Vote: I do not like it