#define _USE_MATH_DEFINES #include //cin, cout #include //vector #include //sort,min,max,count #include //string,getline, to_string #include //abs(int) #include //swap, pair #include //tuple #include //deque #include //INT_MAX #include //bitset #include //sqrt, ceil. M_PI, pow, sin #include //fixed #include //setprecision #include //stringstream #include //gcd, assumlate #include //randam_device #include //numeric_limits #include using namespace std; constexpr long long int D_MOD = 1000000007; int main() { int N, K; string S; cin >> N >> K >> S; string temp1, temp2, temp3; for (int i = 0; i + K <= N; i++) { if (i != 0) { temp1 = S.substr(0, i); } else { temp1 = ""; } temp2 = S.substr(i, K); if (i + K < N) { temp3 = S.substr(i + K); } else { temp3 = ""; } reverse(temp2.begin(), temp2.end()); S = temp1 + temp2 + temp3; } cout << S << endl; return 0; }