Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <map>
- using namespace std;
- int N, K;
- string s, massimo;
- multimap<string, int> pin;
- void caricamento() {
- string temp = "";
- for(int i = 0; i <= N-K; i++) {
- temp = s.substr(i, K);
- pin.emplace(temp, 1);
- temp.clear();
- }
- return ;
- }
- void check() {
- int Max = 0;
- for(auto x: pin) {
- int n = pin.count(x.first);
- if(n > Max) {
- Max = n;
- massimo = x.first;
- }
- }
- }
- int main() {
- cin >> N >> K;
- s.resize(N);
- for(int i = 0; i < N; i++)
- cin >> s[i];
- caricamento();
- check();
- for(char i: massimo)
- cout << i << ' ';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement