Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2014
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <vector>
  4.  
  5. /*
  6. Entrada: Vertices Arestas
  7. 5 10
  8. 1 2 4
  9. 1 3 5
  10. 1 4 7
  11. 1 5 8
  12. 2 3 4
  13. 2 4 5
  14. 2 5 8
  15. 3 4 9
  16. 3 5 11
  17. 4 5 19
  18.  
  19. Com vector:   [1] -> [[2, 4]];
  20.               [1] -> [[3, 5]];
  21. e assim por diante !
  22. */
  23.  
  24. using namespace std;
  25.  
  26. int main(){
  27.     int V, Vi, Vj, A, C;
  28.     long double t;
  29.     long int k = 0;
  30.    
  31.     cin >> V >> A;
  32.     vector<vector<pair<int, int>> > caixeiro(A);
  33.     for(int i = 1; i <= A; i++){
  34.         cin >> Vi >> Vj >> C;
  35.         //Vi = vertice inicial
  36.         //Vj = Vertice que faz ligação com Vi
  37.         //Custo para a ligação
  38.         caixeiro[Vi].push_back(make_pair(Vj, C));
  39.     }
  40.     for(vector<vector<pair<int, int>> >::iterator it = caixeiro.begin()); it != caixeiro.end()); it++{
  41.         cout << *it << ' ';
  42.     }
  43.     cout << endl;
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement