p11506.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #include <iostream>
  2. #include <utility>
  3. #include <list>
  4. #include <vector>
  5. #include <cmath>
  6. #include <limits>
  7. using namespace std;
  8. struct Edge;
  9. struct Node
  10. {
  11. Node(){}
  12. Node(unsigned int size):neighbours{size} {}
  13. int id;
  14. int capacity;
  15. vector<struct Edge*> neighbours;
  16. };
  17. struct Edge
  18. {
  19. Edge(Node *n1, Node *n2, int capacity):n1{n1}, n2{n2}, capacity{capacity}, flow{0}
  20. {
  21. capacity = min(min(n1->capacity, n2->capacity), capacity);
  22. n1->neighbours.push_back(this);
  23. n2->neighbours.push_back(this);
  24. }
  25. Node *n1, *n2;
  26. int capacity;
  27. int flow;
  28. };
  29. int edmonds_karp(vector<Node> m)
  30. {
  31. return 0;
  32. }
  33. int main()
  34. {
  35. int num_machines, num_wires;
  36. while(cin >> num_machines >> num_wires)
  37. {
  38. if(!num_machines && !num_wires)
  39. {
  40. break;
  41. }
  42. vector<Node> machines(num_machines);
  43. machines[0].id = 1;
  44. machines[0].capacity = INT_MAX;
  45. machines[num_machines-1].id = num_machines;
  46. machines[num_machines-1].capacity = INT_MAX;
  47. for(int i = 0; i < num_machines-2; i++)
  48. {
  49. int id, capacity;
  50. cin >> id >> capacity;
  51. machines.at(id-1).id = id;
  52. machines.at(id-1).capacity = capacity;
  53. }
  54. for(int i = 0; i < num_wires; i++)
  55. {
  56. int node1, node2, capacity;
  57. cin >> node1 >> node2 >> capacity;
  58. node1--;
  59. node2--;
  60. Node *n1 = &machines[node1];
  61. Node *n2 = &machines[node2];
  62. new Edge(n1, n2, capacity);
  63. }
  64. cout << edmonds_karp(machines) << endl;
  65. // for(auto m : machines)
  66. // {
  67. // cout << m.id << ":" << m.capacity << endl;
  68. // for(auto n : m.neighbours)
  69. // {
  70. // cout << "\t" << n->n1->id << " <--> " << n->n2->id << ": " << n->capacity << endl;
  71. // }
  72. // }
  73. }
  74. return 0;
  75. }