Submission #70221075
				
			
			
			Source Code Expand
			#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define yn(b) cout << (b ? "Yes" : "No") << endl;
#define YN(b) cout << (b ? "YES" : "NO") << endl;
// #define INTERACTIVE
#ifndef INTERACTIVE
#define endl '\n'
#endif
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? '\n' : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printvm(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i].val() << (i == n - 1 ? '\n' : ' ');}
template<class T> inline void printvvm(vector<vector<T>>& v) {for (auto u : v) printvm(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << '\n';}
// const int MOD = 1000000007;
// const int MOD = 998244353;
// using mint = modint1000000007;
using mint = modint998244353;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
#ifndef INTERACTIVE
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}
vi _r{-1, 0, 1, 0};
vi _c{0, 1, 0, -1};
vi _r8{-1, -1, -1, 0, 1, 1, 1, 0};
vi _c8{-1, 0, 1, 1, 1, 0, -1, -1};
void solve() {
    int n, k;
    string s;
    cin >> n >> k >> s;
    map<string, int> m;
    int mx = 0;
    REP(i, n - k + 1) {
        string t = s.substr(i, k);
        m[t]++;
        chmax(mx, m[t]);
    }
    set<string> ans;
    for (auto [a, b] : m) {
        if (b == mx) ans.emplace(a);
    }
    cout << mx << endl;
    for (auto a : ans) cout << a << " ";
    cout << endl;
}
			
				Submission Info
				
			
			
			
				
					| Submission Time |  | 
				
					| Task | B - Most Frequent Substrings | 
				
					| User | mdstoy | 
				
					| Language | C++ 20 (gcc 12.2) | 
				
					| Score | 200 | 
				
					| Code Size | 2790 Byte | 
				
					| Status | AC | 
				
					
						| Exec Time | 1 ms | 
					
						| Memory | 3676 KiB | 
				
			
Judge Result
				
					
							
								| Set Name | Sample | All | 
							
								| Score / Max Score | 0 / 0 | 200 / 200 | 
							
								| Status |  |  | 
						
 
				
					
						
						
							| Set Name | Test Cases | 
						
						
						
							
								| Sample | 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt | 
						
							
								| All | 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt | 
						
						
					
							
							
								| Case Name | Status | Exec Time | Memory | 
							
							
							
							
								| 00-sample-01.txt | AC | 1 ms | 3548 KiB | 
							
							
								| 00-sample-02.txt | AC | 1 ms | 3544 KiB | 
							
							
								| 00-sample-03.txt | AC | 1 ms | 3412 KiB | 
							
							
								| 01-01.txt | AC | 1 ms | 3552 KiB | 
							
							
								| 01-02.txt | AC | 1 ms | 3488 KiB | 
							
							
								| 01-03.txt | AC | 1 ms | 3548 KiB | 
							
							
								| 01-04.txt | AC | 1 ms | 3556 KiB | 
							
							
								| 01-05.txt | AC | 1 ms | 3484 KiB | 
							
							
								| 01-06.txt | AC | 1 ms | 3416 KiB | 
							
							
								| 01-07.txt | AC | 1 ms | 3484 KiB | 
							
							
								| 01-08.txt | AC | 1 ms | 3552 KiB | 
							
							
								| 01-09.txt | AC | 1 ms | 3448 KiB | 
							
							
								| 01-10.txt | AC | 1 ms | 3676 KiB | 
							
							
								| 01-11.txt | AC | 1 ms | 3560 KiB | 
							
							
								| 01-12.txt | AC | 1 ms | 3452 KiB | 
							
							
								| 01-13.txt | AC | 1 ms | 3536 KiB | 
							
							
								| 01-14.txt | AC | 1 ms | 3412 KiB | 
							
							
								| 01-15.txt | AC | 1 ms | 3488 KiB | 
							
							
								| 01-16.txt | AC | 1 ms | 3480 KiB | 
							
							
								| 01-17.txt | AC | 1 ms | 3472 KiB | 
							
							
								| 01-18.txt | AC | 1 ms | 3480 KiB | 
							
							
								| 01-19.txt | AC | 1 ms | 3620 KiB |