I know of examples that are very similar to your example. I'm not sure how helpful these examples will be. Basically, two indicator functions on any dense subset of the reals will work. For example $f(x) = 1$ and $g(x)$ is the indicator function of the algebraic numbers.
Also, you can do something like $h(x) = 3$ and $k(x) = 3g(x)$.
When $f$ is given, you won't necessarily be able to uniquely find a corresponding $g$. In your example, your $f(x)$ is the indicator function on the rationals. $g(x) = 1$ works just as well as your other $g(x)$. Also, $g(x)=0$ is another possible pair for your $f(x)$. Thus, in the generic case, it seems that you can't uniquely determine a function from that condition.
https://math.stackexchange.com/a/978359/234911
With the above construction, you should be able to come up with examples where you have functions $f_1,...,f_n$ such that $f_i(I) \cap f_j(J) \neq \emptyset %$ for all nonempty open intervals $I$, $J$ and integers $i$, $j$, such that $1 \leq i \leq j \leq n$.