如果你的字符串读入使用scanf或getchar,并且n和k使用scanf或快读(getchar)输入,请在输入n和k后加入
string ss; getline(cin,ss);
来读取第一段末尾的换行符'\r' 或使用cin读入