プライオリティキュー--priority_queue

PRIORITY_QUEUE:プライオリティキュー、自動ソート、デフォルトでは最初の優先順位が高いですが、それは優先順位値が大きいほど、高いと考えているため、デフォルトの並べ替え、それint型の変数が、下降していることに注意してください、ソートちょうど反対を注文。
1. INT変数
PRIORITY_QUEUE <整数、ベクトル<整数> 、以下<INT >> 降順に
PRIORITY_QUEUE <整数、ベクトル<整数> 、大きな<INTを>> 昇順に

2.だけ少ない号の過負荷よりも、それを無効にする種類の構造は、「<」、

ないソート

struct node
{
	int x,y;
};
bool operator <( const node & a, const node & b)//重载运算符
{
	if(a.x!=b.x) return a.x>b.x;
	else
	return a.y>b.y;
}
priority_queue <node > que ;

降順

struct node
{
	int x,y;
};
bool operator <( const node & a, const node & b)//重载运算符
{
	if(a.x!=b.x) return a.x<b.x;
	else
	return a.y<b.y;
}
priority_queue <node > que ;
公開された32元の記事 ウォン称賛14 ビュー1498

おすすめ

転載: blog.csdn.net/weixin_43310882/article/details/104023716