Submission #70227402
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
using vl=vector<ll>; using vvl=vector<vector<ll>>; using vvvll=vector<vector<vector<ll>>>;
using vi=vector<int>; using vvi=vector<vector<int>>; using vvvi=vector<vector<vector<int>>>;
using vd=vector<double>; using vvd=vector<vector<double>>;
using vc=vector<char>; using vvc=vector<vector<char>>;
using vs=vector<string>;
constexpr int dx[]={1,0,-1,0};
constexpr int dy[]={0,1,0,-1};
constexpr ll INF=1000000001000000001;
constexpr ll Inf=100010001;
//#define MINT1000000007
//#define MINT998244353
#ifdef MINT1000000007
constexpr ll MOD=1000000007;using mint=modint1000000007;
#elif defined(MINT998244353)
constexpr ll MOD=998244353;using mint=modint998244353;
#else
using mint=modint;
#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<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
#define Ft first
#define Sd second
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define rep(i,N) for(ll i=0;i<N;i++)
#define repp(i,N) for(ll i=1;i<=N;i++)
#define ALL(A) A.begin(),A.end()
int main() {
ios::sync_with_stdio(false);cin.tie(nullptr);cout<<setprecision(12);
int n,k; cin>>n>>k;
string s; cin>>s;
map<string,int> M;
rep(i,n-k+1){
string ss=s.substr(i,k);
M[ss]++;
}
int ans=0;
for(auto[ss,num]:M){
chmax(ans,num);
}
cout<<ans<<endl;
vs S;
for(auto[ss,num]:M){
if(num==ans)S.emplace_back(ss);
}
sort(ALL(S));
for(string ss:S){
cout<<ss<<' ';
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - Most Frequent Substrings |
| User | ChuChoku |
| Language | C++ 20 (gcc 12.2) |
| Score | 200 |
| Code Size | 1876 Byte |
| Status | AC |
| Exec Time | 2 ms |
| Memory | 3536 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 | 2 ms | 3388 KiB |
| 00-sample-02.txt | AC | 1 ms | 3524 KiB |
| 00-sample-03.txt | AC | 1 ms | 3464 KiB |
| 01-01.txt | AC | 1 ms | 3528 KiB |
| 01-02.txt | AC | 1 ms | 3532 KiB |
| 01-03.txt | AC | 1 ms | 3516 KiB |
| 01-04.txt | AC | 1 ms | 3536 KiB |
| 01-05.txt | AC | 1 ms | 3440 KiB |
| 01-06.txt | AC | 1 ms | 3456 KiB |
| 01-07.txt | AC | 1 ms | 3524 KiB |
| 01-08.txt | AC | 1 ms | 3384 KiB |
| 01-09.txt | AC | 1 ms | 3464 KiB |
| 01-10.txt | AC | 1 ms | 3516 KiB |
| 01-11.txt | AC | 1 ms | 3388 KiB |
| 01-12.txt | AC | 1 ms | 3340 KiB |
| 01-13.txt | AC | 1 ms | 3464 KiB |
| 01-14.txt | AC | 1 ms | 3520 KiB |
| 01-15.txt | AC | 1 ms | 3456 KiB |
| 01-16.txt | AC | 1 ms | 3356 KiB |
| 01-17.txt | AC | 1 ms | 3472 KiB |
| 01-18.txt | AC | 1 ms | 3452 KiB |
| 01-19.txt | AC | 1 ms | 3348 KiB |