int main() { std::string keyword; std::cin >> keyword; // 读取关键字 int count = 0; std::cin >> count; std::vector<std::string> contents; // 每行的数据 for(int i = 0;i<count;++i){ std::string tmp; std::cin >> tmp; contents.push_back(tmp); } // < -数量,node> std::vector<pair<int, Tree*>> vec; for (int i = 0; i < contents.size(); i++) { int tmp = get(contents[i]); string tmp2 = contents[i].substr(tmp); Tree* node = new Tree(tmp2, vector<Tree*>()); vec.push_back({tmp, node}); } // 构建N叉树 deque<int> deq; deq.push_back(0); for (int i = 1; i < contents.size(); i++) { while (get(contents[i]) <= vec[deq.front()].first) { deq.pop_back(); } Tree* node = vec[deq.front()].second; node->child.push_back(vec[i].second); deq.push_back(i); } aa(vec[0].second, keyword); for (auto i : result) { cout << i << endl; } return 0; }
点赞 评论

相关推荐

牛客网
牛客网在线编程
牛客网题解
牛客企业服务