1 条题解
-
0
#include <bits/stdc++.h> using namespace std; const int N = 1e5+5; struct node{ int nxt,pre; }a[N]; int n,m,x,p;a[0] void ins(int x, int y,int p){ if(p){ a[y].nxt = a[x].nxt; a[y].pre = x; a[a[x].nxt].pre = y; a[x].pre = a[x].pre; a[a[x].pre].nxt=y; a[x].pre = y; } } void del(int x){ if(a[x].nxt ==0&&a[x].pre ==0){ return; } a[a[x].pre].nxt=a[x].nxt; a[a[x].nxt].per=a[x].pre; a[x].nxt = a[x].pre = 0; } int main(){ cin >> n; a[0].nxt = 1; for(int i = 2;i<=n;i++){ cin >> x >> p; ins(x,i,p); } cin >> m; for(int i = 1;i<=m;i++){ cin >> x; del(x); } return 0; }
- 1
信息
- ID
- 3559
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 6
- 标签
- (无)
- 递交数
- 33
- 已通过
- 11
- 上传者