-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4097.cpp
More file actions
executable file
·43 lines (39 loc) · 775 Bytes
/
Copy path4097.cpp
File metadata and controls
executable file
·43 lines (39 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* 模拟
**/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
int dt[100233], N, M, op;
void insert(int x, int y) {
++ N;
for(int i = N;i > x + 1;-- i)
dt[i] = dt[i - 1];
dt[x + 1] = y;
}
void del(int x) {
-- N;
for(int i = x;i <= N;++ i)
dt[i] = dt[i + 1];
}
int main() {
scanf("%d%d", &N, &M);
for(int i = 1;i <= N;++ i)
scanf("%d", &dt[i]);
for(int i = 0;i < M;++ i) {
scanf("%d", &op);
if(op == 1) {
int x, y;
scanf("%d%d", &x, &y);
insert(x, y);
} else {
int x;
scanf("%d", &x);
del(x);
}
}
for(int i = 1;i <= N;++ i)
printf("%d ", dt[i]);
printf("\n");
}