On the complexity of the word problem for automaton semigroups and automaton groups