Announcing that you re gonna enter the opposing gender bathroom, then after waiting a bit enter, use the bathroom and get out.
Had it once @ a festival where the door to the toilet simply couldn't be opened as someone managed to get the lock jammed, as i had to shit i couldn't use the urinals, so i did whats described above.
What is there to discuss, you as a human being have to go to the toilet, the one assigned to you based on gender isn't available, use the available one.