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

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

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?

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

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

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

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

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

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

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

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?

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

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

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

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.

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

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

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

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.

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

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

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

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?

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

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

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

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?

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

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

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

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?

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

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

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

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

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

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

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

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.

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

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