Finite Automata Based Algorithms for the Generalized Constrained Longest Common Subsequence Problems