#include <bits/stdc++.h> using namespace std; int n, k; string s; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> k; cin >> s; int idx = s.find("mihoyo"); int ans = 2 * n; vector<int> a; int pre = 0; while (idx != -1) { a.push_back(idx + pre); pre = pre + idx + 6; string tmp = s.substr(pre); idx = tmp.find("mihoyo"); } if (a.size() < k) { cout << -1 << endl; return 0; } int l = 0, r = 0; int ll, rr; while (r < a.size()) { while (r < a.size() &;&; (r - l) < k - 1) { r++; } if (r == a.size()) break; int end = a[r] + 5; int begin = a[l]; if (end - begin + 1 < ans) { ans = end - begin + 1; ll = begin, rr = end; } l++; } cout << ll << " " << rr << endl; return 0; }

相关推荐

牛客网
牛客企业服务