Also, a shared apartment costs as much as you say. Not a room (source: idealista.es).
Purchase prices are high, but I'm curious as to what you consider a bad neighborhood, given the overall safety statistics in Spain, and Madrid in particular.
Housing affordability is a real problem, but misrepresenting data is counterproductive, as it can be easily disproven.