Maybe it is better to start with a contradiction.
Let . Then there exists a x1 such that f(x1) = x2 and x1<>x2
fof(x1) = f(x1) ---- by your definition of f
also fof(x1) = f(f(x1)) = f(x2)
thus f(x1) = f(x2) => f is not one-to-one
Can you try to complete?