嚴正注意,以下對dijkstra+臨接表的代碼進行更正。

原來錯誤部分

struct Node {
	int v,w; 
	Node() {}
	Node ( int a_ ,int b_ ) {	v = a_ ; w = b_ ; }
	bool operator < ( const Node& aaa ) const {
		return w < aaa.w; 
	}
};

更正部分

struct Node {
	int v,w; 
	Node() {}
	Node ( int a_ ,int b_ ) {	v = a_ ; w = b_ ; }
	bool operator < ( const Node& aaa ) const {
		return w > aaa.w; 
	}
};

符號的更改不會影響到部分題目的正確性

意義上,後者纔是正確的。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章