Advertisement
Georgiy1108

Untitled

Sep 23rd, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5.     int n, m, mx = 0;
  6. vector<int> color;
  7. vector<pair<int, int>> r;
  8.  
  9. int check(vector<int> color)
  10. {
  11.     int cnt = 0;
  12.     map<pair<int, int>, int> mp;
  13.     for(auto i : r)
  14.     {
  15.         if(mp.count({min(color[i.first], color[i.second]), max(color[i.first], color[i.second])}) == 0)
  16.         {
  17. //          cout << min(color[i.first], color[i.second]) << " " << max(color[i.first], color[i.second]) << "\n";
  18.             cnt++;
  19.             mp[{min(color[i.first], color[i.second]), max(color[i.first], color[i.second])}] = 1;
  20.         }
  21.     }
  22.     return cnt;
  23. }
  24.  
  25. void f(int i, vector<int> color)
  26. {
  27.     if(i == n + 1)
  28.     {
  29. //      for(int i = 0; i < n; i++)
  30. //          cout << color[i] << ' ';
  31. //      cout << "\n";
  32.         mx = max(check(color), mx);
  33.         return;
  34.     }
  35.     for(int j = 1; j <= 6; j++)
  36.     {
  37.         color[i] = j;
  38.         f(i + 1, color);
  39.     }
  40. }
  41.  
  42. main()
  43. {
  44.    
  45.     cin >> n >> m;
  46.     for(int i = 0; i < m; i++)
  47.     {
  48.         int f, t;
  49.         cin >> f >> t;
  50.         r.push_back({f, t});
  51.     }
  52.     color.resize(n + 1, 0);
  53.     set<int> s{1, 2, 3, 4, 5, 6, 7};
  54.     f(1, color);
  55.    
  56.     cout << mx;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement