Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int n, m, mx = 0;
- vector<int> color, used;
- vector<pair<int, int>> r;
- int check(vector<int> color)
- {
- int cnt = 0;
- map<pair<int, int>, int> mp;
- for(auto i : r)
- {
- if(mp.count({min(color[i.first], color[i.second]), max(color[i.first], color[i.second])}) == 0)
- {
- cnt++;
- mp[{min(color[i.first], color[i.second]), max(color[i.first], color[i.second])}] = 1;
- }
- }
- return cnt;
- }
- void f(int i, vector<int> color, vector<int> used)
- {
- if(i == n + 1)
- {
- mx = max(check(color), mx);
- return;
- }
- for(int j = 1; j <= 6; j++)
- {
- if(used[j] == 1)
- {
- color[i] = j, used[j]++;
- f(i + 1, color, used);
- }
- else if(used[j] == 0)
- {
- color[i] = j, used[j]++;
- f(i + 1, color, used);
- }
- else if(used[j] > 1)
- continue;
- }
- }
- main()
- {
- cin >> n >> m;
- for(int i = 0; i < m; i++)
- {
- int f, t;
- cin >> f >> t;
- r.push_back({f, t});
- }
- color.resize(n + 1, 0);
- used.resize(7, 0);
- set<int> s{1, 2, 3, 4, 5, 6, 7};
- f(1, color, used);
- cout << mx;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement