Automaton recognizing ambiguously accepted words of another automaton Let $A$ be a nondeterministic automaton. Let $X(A)$ the set of words for which there at least two accepting paths.

In one of the previous exam, for which no answers are available, it is required to prove that there exist a deterministic automaton whose language is $X(A)$. Furthermore, if the original automaton has $k$ states, then the new automaton should have $3^k$ states.

I have tried multiples approaches to no avail:


Make an automata that keeps track of which path was taken, but the size of the automata grew infinitely because of cycles...
An automaton for each state I also kept track of which state it came from, but it was just a scaled down version of previous attempt. Which didn't work if the path started to converge early.
Tried an automaton where I encoded each state with the set of all the states from automaton $A$. And for each state I included whether I went through that state 0, 1 or more than 2 times.
Construct an NFA which will simulate (nodeterministically) two runs of the original NFA on the input. The NFA also remembers one bit – whether the two runs have diverged so far or not. If the bit is off and the NFA chooses two different transitions, then you turn it on. The NFA accepts if both runs accept and the bit is on.

If the original NFA has $k$ states, then the new NFA will have $2k^2$ states. You can convert it to a DFA with $4^{k^2}$ states.

We can reduce the number of states in the corresponding DFA by performing the powerset construction directly. At each step, we will remember, for each step, whether (i) it is impossible to be at that state, (ii) it is possible to be at that state, but there is a unique such run, (iii) it is possible to be at the state, and there are at least two such runs. A state is accepting if there is an accepting states of type (iii), or at least two accepting states of type (ii). This construction uses only $3^k$ states, and so matches your hint.