Please read the new rule regarding the restriction on the use of AI tools. ×

bus_u_he's blog

By bus_u_he, history, 2 months ago, In English

You are given a character matrix where each cell can contain one of the following characters:

U: You can move up from this cell with zero cost. Moving in any other direction from this cell incurs a cost of 1. R: You can move right from this cell with zero cost. Moving in any other direction from this cell incurs a cost of 1. L: You can move left from this cell with zero cost. Moving in any other direction from this cell incurs a cost of 1. D: You can move down from this cell with zero cost. Moving in any other direction from this cell incurs a cost of 1.

You need to determine the minimum cost to travel from a starting coordinate (x, y) to a target coordinate (a, b) within the matrix. You are not allowed to move outside the boundaries of the matrix.

Input A character matrix grid of size m x n. Starting coordinates (x, y). Target coordinates (a, b). Output An integer representing the minimum cost to travel from (x, y) to (a, b). Input: grid = [ ['R', 'R', 'D'], ['L', 'D', 'D'], ['U', 'U', 'R'] ] x = 0, y = 0 a = 2, b = 2

Output: 0 Explanation In the given example:

Start at (0, 0) with 'R', move to (0, 1) with zero cost. From (0, 1), move to (0, 2) with zero cost (again 'R'). From (0, 2), move down to (1, 2) with zero cost (cell is 'D'). Finally, from (1, 2), move to (2, 2) with zero cost (cell is 'D'). The total cost is 0, as each move is in the optimal direction with zero cost.

Constraints The dimensions of the matrix m and n will be between 1 and 1000. The starting and target coordinates will always be within the matrix boundaries. I thought of using bfs and saving minimum cost but wasn't able to implement my logic properly can someone help me please

Full text and comments »

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

By bus_u_he, history, 2 months ago, In English

As a computer science enthusiast, you’ve probably spent countless hours grappling with binary trees, but have you ever wondered if they could bear fruits?

Full text and comments »

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

By bus_u_he, history, 2 months ago, In English

Hello Codeforces Community,

I've spent a significant amount of time on this platform and have learned quite a few things. Sometimes, I feel a strong desire to give back to the community by contributing a problem or testing a contest. However, I'm unsure how to get started with these activities.

Can someone guide me on how I can submit my problems for inclusion in a Codeforces contest? If any of you have experience in these areas, I'd love to hear about your journey and what it was like for you.

Thank you!

Full text and comments »

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

By bus_u_he, history, 2 months ago, In English

I recently took an OA with a question involving n arrays of size m. The task was to create an array A of size n by choosing one element from each array. Then, we had to find the minimum value of A0 | A1 | A2 | ... | An-1 (bitwise OR of all elements in A) and n<1000,m<1000 and each element in those n arrays is less than 100000.

I used recursive DP, considering two options: either go forward in the same array or pick the current element and move to the start of the next array. However, this approach gave incorrect results for 3 out of 10 test cases. Can anyone help me identify what I missed or if I made an unforced error?

Full text and comments »

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