map无脑过
子串计算
https://www.nowcoder.com/practice/bcad754c91a54994be31a239996e7c11
#include <iostream> #include <vector> #include <algorithm> #include <map> using namespace std; string str; map<string, int> tree_map; int main() { cin >> str; for (int i = 0; i < str.size(); ++i) for (int j = i; j < str.size(); ++j) { string t = str.substr(i, j - i + 1); tree_map[t]++; } for (auto [u, v] : tree_map) if (v > 1) cout << u << ' ' << v << endl; return 0; }