Update tensor values based on the arange of each row from another tensor

Given a 1D pytorch tensor, I want to update specific elements as following:

import torch 
x = torch.zeros(10) 
idx = torch.LongTensor([[0,1], [3,5], [6,8]]) 
for i in range(idx.shape[0]): 
    x[torch.arange(idx[i][0], idx[i][1])] = 1 

Expected output:

tensor([1., 0., 0., 1., 1., 0., 1., 1., 0, 0]

How can I vectorize this using pytorch? Many thanks in advance.