用了双端队列模拟循环链表比较简单
#include <iostream>
#include <deque>
#include <string>
using namespace std;
const int N = 1e5 + 10;
struct person {
string name;
string id;
int age;
string sex;
string Class;
string st;
}p[N];
int n, m;
deque<person> q;
void solve() {
int i = 0;
while(q.size()) {
auto t = q.front();
q.pop_front();
i ++;
if(i == m) {
i = 0;
cout << t.name << ' ' << t.id << ' ' << t.sex << t.age << ' ' << t.Class << ' ' << t.st << endl;
}
else {
q.push_back(t);
}
}
}
int main() {
cin >> n >> m;
for(int i = 1; i <= n; i ++ ) {
cin >> p[i].name >> p[i].id >> p[i].sex >> p[i].age >> p[i].Class >> p[i].st;
// cout << p[i].name << ' ' << p[i].id << ' ' << p[i].sex << p[i].age << ' ' << p[i].Class << ' ' << p[i].st << endl;
q.push_back(p[i]);
}
solve();
return 0;
}