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

Автор black_hatinside, история, 17 месяцев назад, По-английски

Is codeforces down? Please let me know guys, my solutions aren't getting submitted.

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

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

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

Trying to implement the system design of Uber where I am allowed to add new locations and new routes to those locations anywhere in the map. How can I optimize my Dijkstra algorithm so that I don't have to run it for all the nodes everytime I add a new edge or node to my graph (map).

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

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

Автор black_hatinside, 3 года назад, По-английски

Submissions to some old problems (without clear editorials or solutions) are greyed out. How can I know the solution to such problems in Codeforces?

The problem I am trying to learn: https://mirror.codeforces.com/gym/102760/problem/F

Words on Editorial: "There is another, more difficult solution. If you know how to find the largest rectangle in the histogram inO(N) using a stack, then you may realize that you can actually apply the exact same strategy to find the largest square. The proof is left to the reader for exercise."

And my solution

n = int(input())
arr = list(map(int, input().split()))

def solve(heights):
    maxside = 0
    pstack, hstack = [], []
    currarea, maxside = 0, 0
    heights.append(0)
    for i in range(len(heights)):
        prevwidth = int(1e9)
        while hstack != [] and hstack[-1] > heights[i]: # -_
            prevwidth = pstack[-1]
            width = i - pstack.pop()
            height = hstack.pop()
            if width == height:
                maxside = max(maxside, width)
        if maxside < heights[i] or not hstack or hstack[-1] < heights[i]: # _-
            hstack.append(heights[i])
            pstack.append(min(prevwidth, i))
    return maxside

ans = solve(arr)
print(ans)

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

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

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

CP gives me both happiness and stress. So I am interested in knowing what people in this community do when they are in anxiety or down in life or when they have tried hard to solve a problem, but never succeeded. Should I make friends to do CP or solving problems alone is enough?

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

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

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

Should you be stuck with a problem for long hours and try to come up with a solution or should you spend a hour or so for a problem and then give up and get hints from editorial and try again? I feel guilty for seeing the editorial. (^_^)!

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

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