Imagine a landlord demanding that a black renter agree not to use the white laundry room before being allowed to rent. Think that paper would stand up in court?
That's not true at all. I may have "freedom of speech" but I've signed corporate agreements in which I cannot speak ill of the company (whether truthful or not) as a condition of employement or severance package. These are binding and can be upheld in court.
I agree with that as a general proposition. What you are likely to find in this situation, however, is that a court would say the university had a right to reasonably inspect the rooms for unsafe conditions and material and that the students, warned in advance of this right of inspection, (a) had no expectation of privacy, and (b) had consented to the searches.