Files
python/TangDou/XiTi/1346.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

34 lines
767 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> v1;
for (int i = 0; i < n; i++) {
v1.push_back(i + 1);
}
for (int i = 0; i < m; i++) {
int p, q;
cin >> p >> q;
//3 2 :表示3号同学出列向后移动2个距离
int inx = -1;
for (int j = 0; j < n; j++) {
if (v1[j] == p) {
inx = j;
break;
}
}
//(1)出列即删除
v1.erase(v1.begin() + inx);
//(2)移动就是插入
v1.insert(v1.begin() + inx + q, p);
}
for (int i = 0; i < n; i++) {
cout << v1[i] << " ";
}
cout << endl;
return 0;
}