Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string.h>
- #include <iostream>
- #include <cstdio>
- #include <ctime>
- #include <algorithm>
- #include <vector>
- #include <set>
- #include <cmath>
- #include <string>
- #include <map>
- #include <cassert>
- #include <queue>
- using namespace std;
- #define forn(i, n) for (int i = 0; i < int(n); i++)
- const int N = 25;
- int n, m;
- vector<int> g[N];
- long long z[1 << N];
- long long calc(int mask)
- {
- if (z[mask] > -1)
- return z[mask];
- if (mask == 0)
- return (z[mask] = 0);
- int pos = -1;
- forn(i, n)
- if (mask & (1 << i))
- pos = i;
- long long result = calc(mask ^ (1 << pos));
- forn(i, g[pos].size())
- {
- int j = g[pos][i];
- if (mask & (1 << j))
- result = max(result, 1 + calc(mask ^ (1 << pos) ^ (1 << j)));
- }
- return (z[mask] = result);
- }
- int main()
- {
- cin >> n >> m;
- forn(i, m)
- {
- int a, b;
- cin >> a >> b;
- g[a - 1].push_back(b - 1);
- g[b - 1].push_back(a - 1);
- }
- memset(z, -1, sizeof(z));
- cout << calc((1 << n) - 1) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement