Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main()
- {
- get_input();
- d[1][1].cost = 0;
- d[1][1].tel = 0;
- to.planet = 1;
- to.anc = 1;
- to.cost = 0;
- to.tel = 0;
- q.insert( to );
- while( !q.empty() )
- {
- now = *q.begin();
- q.erase( q.begin() );
- for( i=0; i < g[ now.planet ][ now.anc ].size(); i++ )
- {
- P = g[ now.planet ][ now.anc ][i].planet;
- C = g[ now.planet ][ now.anc ][i].cost;
- A = g[ now.planet ][ now.anc ][i].anc;
- T = g[ now.planet ][ now.anc ][i].tel;
- if( d[P][A].tel > now.tel+T || (d[P][A].tel == now.tel+T && d[P][A].cost > now.cost+C) )
- {
- to.planet = P;
- to.anc = A;
- to.cost = d[P][A].cost;
- to.tel = d[P][A].tel;
- q.erase( to );
- d[P][A].cost = now.cost+C;
- d[P][A].tel = now.tel+T;
- to.cost = d[P][A].cost;
- to.tel = d[P][A].tel;
- q.insert( to );
- }
- }
- }
- printf( "%lld %lld", d[n][k].tel, d[n][k].cost );
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement