const vector lcs_vt(const string &str1, const string &str2) { int col_num = str1.length(); int row_num = str2.length(); int map[row_num][col_num]; bzero(map, sizeof(map)); vector ret; for(int i = 0; i < col_num; i++) { for(int j = 0; j < row_num; j++) { if (str1[i] == str2[j]) { map[j][i] = 1; } } } int list_flag = 0; string temp; for (int i = col_num - 1; i >= 0; i--) { int j = 0; temp = ""; while(j + i < col_num && j < row_num) { if (map[j][j + i] == 1) { temp += str1[j + i]; } else { temp += '#'; } j++; } vector splited_str = split_with_string(temp, "#"); vector_unique(splited_str); for(unsigned int i = 0; i < splited_str.size(); i++) { ret.push_back(splited_str[i]); } } for (int i = 1; i < row_num; i++) { int j = 0; temp = ""; while(j < col_num && j + i < row_num) { if (map[j + i][j] == 1) { temp += str2[j + i]; } else { temp += '#'; } j++; } //if (!(temp.empty())) { // cout << "###" << temp << endl; //} vector splited_str = split_with_string(temp, "#"); vector_unique(splited_str); for(unsigned int i = 0; i < splited_str.size(); i++) { ret.push_back(splited_str[i]); } } return ret; }