Advertisement
Guest User

Untitled

a guest
May 24th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include "Set.h"
  4. #include "Vector.h"
  5.  
  6. #define MAXN 100
  7.  
  8. using namespace std;
  9.  
  10. Set < int > FinalSet(MAXN);
  11. bool found = false;
  12. Vector < int > G[MAXN];
  13.  
  14. void Bron(Set < int > R, Set < int > P, Set < int > X) {
  15. if(P.empty() && X.empty()) {
  16. FinalSet = R; /*aici*/
  17. found = true;
  18. }
  19.  
  20. int l = P.size();
  21. while(l --) {
  22. int v = (P.begin());/*aici*/
  23. Set < int > newP(MAXN), newX(MAXN);
  24.  
  25. for(int i = 0; i < (int) G[v].mySize(); ++ i) {
  26. if(P.find(G[v][i])) {/*aici*/
  27. newP.insert(G[v][i]);
  28. }
  29.  
  30. if(X.find(G[v][i])) {/*aici*/
  31. newX.insert(G[v][i]);
  32. }
  33. }
  34.  
  35. if(!found) {
  36. R.insert(v);
  37. Bron(R, newP, newX);
  38. R.erase(v);/*aici*/
  39.  
  40. P.erase(P.begin());/*aici*/
  41. X.insert(v);
  42. }
  43. }
  44. }
  45.  
  46. int main() {
  47. int m, n, x, y;
  48. Set < int > P(MAXN), R(MAXN), X(MAXN);
  49. scanf("%d%d", &n, &m);
  50. while(m--) {
  51. scanf("%d%d", &x, &y);
  52. G[x].push_back(y);
  53. G[y].push_back(x);
  54. P.insert(x);
  55. P.insert(y);
  56. }
  57.  
  58. Bron(R, P, X);
  59.  
  60. //printf("%lu\n", FinalSet.size());
  61.  
  62. //for(Set < int > :: iterator it = FinalSet.begin(); it != FinalSet.end(); ++ it)
  63. // printf("%d ", *it);
  64.  
  65. printf("\n");
  66. return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement