When a contestant of a
competition has no
probability of winning, but wins anyhow, it is a longshot.
When you try to guess a result of something, but in fact
you don't know at all what will be the outcome of it, that is a longshot, it is a wild guess.