This code should work:
idx_v = torch.tensor([1,2,4,0,3])
A = torch.tensor([[1, 1, 1, 1, 1],
                  [1, 1, 1, 1, 1],
                  [1, 1, 1, 1, 1],
                  [1, 1, 1, 1, 1],
                  [1, 1, 1, 1, 1]])

torch.arange(idx_v)
res = torch.zeros_like(A).scatter_(1, idx_v.unsqueeze(1), 1)
res = torch.cumsum(res, 1)
print(res)
> tensor([[0, 1, 1, 1, 1],
          [0, 0, 1, 1, 1],
          [0, 0, 0, 0, 1],
          [1, 1, 1, 1, 1],
          [0, 0, 0, 1, 1]])