finally got ac, same algorithm, just rewrite