跳到正文

个人记录

duilie

用户 961054约 2 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 2 分钟

版本

  1. v1当前

//P1160 队列安排 #include<cstdio> #include<list>

using namespace std ;

const int N = 1e5 + 10 ;

list<int> mylist ; list<int>::iterator ait[N] ;

int n , m ;

int main() { scanf(“%d” , &n) ;

C++
list<int>::iterator it ;

mylist.push_back(1) ;
ait[1] = mylist.begin() ;

for(int i = 2 ; i <= n ; ++ i)
{
	int x , y ;

	scanf("%d%d" , &x , &y) ;

	if(y)
	{
		it = ait[x] ;
		mylist.insert(++ it , i) ;
		ait[i] = -- it ;
	}
	else
	{
		it = ait[x] ;
		mylist.insert(it , i) ;
		ait[i] = -- it ;
	}
}

scanf("%d" , &m) ;

while(m --)
{
	int x ;

	scanf("%d" , &x) ;

	if(ait[x] != mylist.end())
		mylist.erase(ait[x]) ;

	ait[x] = mylist.end() ;
}

for(it = mylist.begin() ; it != mylist.end() ; ++ it )
	printf("%d " , *it) ;

return 0 ;

}

原文