最短路 次短路 k短路(k很小)
最短路 luogu 3371 https://www.luogu.org/problemnew/show/P3371 1 #include <cstdio> 2 #include <cstdlib> 3 #include <cstring> 4 #include <queue> 5 #include <algorithm> 6 using namespace std; 7 const int maxn=1e4+10; 8 9 int dist[maxn]; 10 bool vis[maxn]; 11 12 struct node 13 { 14 int d,len; 15 ///相反 16 bool operator<(const node & b) const 17 { 18 return b.len<len; ///b.d放在左边,方便 19 } 20 }; 21 22 priority_queue<node> st;///这样写就可以了,省略后面的部分 23 vector<pair<int,int> >e[maxn]; 24 25 int main() 26 { 27 int n,m,s,x,y,z,d,i; 28 vector<pair<int,int> >::iterator j; 29 scanf("%d%d%d",&n,&m,&s); 30 for (i=1;i<=m