The distance for a train to cross a bridge or a cave is the length of the bridge (hole) plus the length of the car body. The length of the two conditions to be reduced is 530-380 = 150m, so the speed is150/(40-30) =15m/s. ..
So when crossing the cave, the distance traveled by the train is 15 * 30 = 450m. Body length 450-380=70 meters.