Start from Sub-diameter

Revision en4, by ASO, 2021-11-08 20:11:22

Given n*n matrix with m query, standing in one of sub-diameter block in the matrix and each step can go only up or left(according to given direction) until you reached a block which visited earlier. what is the best algorithm?

n <= 1e9
m <= 2 * 1e5
input 
6 5 
3 4 U
6 1 L
2 5 L
1 6 U
4 3 U
output
4
3
2
1
2

input
10 6
2 9 U
10 1 U
1 10 U
8 3 L
10 1 L
6 5 U
output
9
1
10
6
0
2
Tags data structures

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en6 English ASO 2021-11-08 20:21:22 57
en5 English ASO 2021-11-08 20:11:46 0 (published)
en4 English ASO 2021-11-08 20:11:22 22
en3 English ASO 2021-11-08 20:09:49 6
en2 English ASO 2021-11-08 20:08:57 6 Tiny change: '1e5\ninput\n6 5\n3 4' -> '1e5\ninput \n6 5\n3 4'
en1 English ASO 2021-11-08 20:07:54 431 Initial revision (saved to drafts)