ay2306's blog

By ay2306, history, 4 years ago, In English

I have a few questions:

  • When you saw this question, did you already know how to approach it?
  • Did you look something up the internet which helped you solve it, if yes then how did you know what to search?
  • If you knew how to solve it using common competitive programming Algorithms/Data Structure, then what did you use?

Full text and comments »

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

By ay2306, history, 6 years ago, In English

Hey codeforces community,

Our coding club is organizing a contest on hackerrank, I am extremely excited to invite all of you to take part in it in order to promote competitive programming culture in I.P. University and New Delhi. Details of the contest are given below, please do take part in it. We will be posting editorial as well.

Contest Registration Link

Full text and comments »

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

By ay2306, history, 6 years ago, In English

I was solving this question on codeforces, and was getting TLE for large test cases. I read a blog about different implementation for compare function on coderfoces and changed my compare function to the third option.

After reading a comment saying that bigger sq can decrease runtime, so decided to give it a try. And it worked, I changed my sq size to 1000 and code was accepted.

What I want to ask is

  1. How size of sq ( = sqrt(n) ) changes runtime?
  2. Should I choose a considerable size myself?
  3. How can I optimize my code as it is just passing by bare minimum of time limit?

Full text and comments »

  • Vote: I like it
  • -4
  • Vote: I do not like it

By ay2306, history, 6 years ago, In English

I learned square-root decomposition from geeksforgeeks and decided to practice by solving questions. But I am unable to grasp the reason of why my code is making an error

Link to my code

To learn without seeking to blog, I tried to look someone's code and implement it myself. I copied down some code but am unable to look why is my code wrong.

Link to original code

Link to code i wrote copying

Where am I going wrong. Please help me.

Thank you.

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By ay2306, history, 6 years ago, In English

Hey guys, I have been surfing the internet for a while but could not get a decent way to write an essay in which I can write down mathematical equations efficiently. I have to submit an essay in one of my course and that includes some mathematical equations (actually depends on it). I was thinking of going with markdown and latex and then convert it to PDF but I am unable to find an offline engine to preview so and all. Please help me with this.

Thanks.

Full text and comments »

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

By ay2306, history, 6 years ago, In English

I am working on a question like, there is given a m × n grid. Each cell holds value. What is the total number of paths from (a, b) to (c, d) given the sum of the values of cell in the path is m.

Possible movements from (i, j) are (i, j)→(i + 1, j), (i, j)→(i−1, j), (i, j)→(i, j + 1), (i, j)→(i, j−1)

I know it can be solved with dynamic programming but I was too much confused to what should I store. Because as contrasting to maximum cost path, it was not a stable value. What should I do in such case?

Full text and comments »

  • Vote: I like it
  • -3
  • Vote: I do not like it

By ay2306, history, 6 years ago, In English

I studied about greedy algorithms and found that all we have to do is try a locally optimal solution and hope it turns out to be globally optimal. But my problem is how to find a locally optimal solution when logic I am developing is already taking global optimal solution.

For example, I was working on some greedy example and came across this question. In this question my local optimal approach was that I will check if Current fuel can travel out of the forest, if not then refuel but then it bombed me with a limitation of availability fuel at a stop so I was now deep struck into thinking how to solve it. So doesn't this require a solution where local optimal won't work because we need to have a knowledge of all stops and amount of fuel they require

As in,

Let's say we were at a stop which can provide 2 unit fuel and we have 4 units of fuel, and two other stops are at distance 2 unit each consecutively, but next one provides 100 units fuel(which can cover whole travel) and one after that makes me stop.

So what should be the local optimal solution approach here, because I am unable to find any without taking the whole scenario into account?

Full text and comments »

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

By ay2306, history, 6 years ago, In English

I was solving a question on codeforces. Sample test case are giving me correct answer in terminal but it is different in codeforces submission.

Link to submission. My terminal gives me a correct answer of

yes 1 3

but it is no in codeforces. How do I debug in such a situation?

Full text and comments »

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

By ay2306, history, 6 years ago, In English

I don't know if this is a bug in codeforces or something I am doing. Tell me if it is something I am wrong somewhere

Problem: Boys and Girls

Bug: Link

SOLVED

Full text and comments »

Tags bug
  • Vote: I like it
  • +3
  • Vote: I do not like it

By ay2306, history, 6 years ago, In English

I am progressing a little day by day but I don't know if I am going in the right direction or if the direction is right but the method I chose is slow. I do want to ask your opinion about what will improve skills more?

  1. Practice algorithms on basis of whatever I find and solve multiple problems for the topic starting from easy to hard.

  2. Open up a previous contest and try to code all those problems, reading the editorial and then learning related algorithms and Data Structure.

I am focusing on option 2 nowadays but would appreciate your opinion on approach of improving skills.

Full text and comments »

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