#include #include #include #include #include using namespace std; #define pi pair vectorgr[10000]; int n,m,start,dist[10000]; bool used[10000]; void init(){ int from,to,weight; scanf("%d %d %d",&n,&m,&start); for(int i=0;i,greater >toVisit;///pairs, first is the distance, second is the node. By default pairs are compared by first element ///if the first elements are equal, then the second. fill(dist,dist+n,INT_MAX);///setting all distances to inf toVisit.push({0,start});///adding starting node dist[start]=0;///distance to first node is 0 while(!toVisit.empty()){///while there are still unvisited nodes node=toVisit.top().second;///we need only the node, the distance is available in the distance array toVisit.pop(); if(used[node])continue;///this is not the first time we meet the node, nothing to do used[node]=1; for(int ind=0;ind