Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Philip_PV
- #include <fstream>
- #include <iostream>
- #include <set>
- #include <map>
- #include <string>
- #include <vector>
- #include <list>
- #include <queue>
- #include <deque>
- #include <stack>
- #include <bitset>
- #include <functional>
- #include <numeric>
- #include <utility>
- #include <sstream>
- #include <iomanip>
- #include <cstdio>
- #include <cstdlib>
- #include <algorithm>
- #include <cassert>
- #include <ctime>
- #include <memory.h>
- //#include <cmath>
- using namespace std;
- typedef long long ll;
- typedef pair<double, double> pdd;
- typedef pair<int, int> pii;
- /*
- #define x first
- #define y second
- //*/
- inline int nextint() {
- int res = 0;
- char c = 0; while (c < '0' || c > '9') c = getchar();
- while (c >= '0' && c <= '9') {
- res = res * 10 + c - '0';
- c = getchar();
- }
- return res;
- }
- #ifdef _DEBUG
- #define dbg(x) { cerr << #x << " = " << x << endl; }
- #else
- #define dbg(x) ;
- #endif
- #define forn(_i,_n) for (int _i = 0; _i < (int)(_n); ++_i)
- #define mp make_pair
- int n;
- map<int, ll> M;
- bool g[50][50];
- vector<pair<int, int> > masks;
- int now;
- void push(int mask, int pos, int left) {
- if (!left) {
- masks.push_back(mp(now, mask));
- return;
- }
- while (true) {
- if (pos + left > n) return;
- int m = mask | (1 << pos);
- push(m, pos + 1, left - 1);
- ++pos;
- }
- }
- void build(int N) {
- now = 2 * N;
- int m = (1 << N) - 1;
- push(m, N, N);
- }
- map<int, ll> dp;
- int main() {
- int m;
- cin >> n >> m;
- forn (i, m) {
- int a, b;
- cin >> a >> b;
- --a; --b;
- g[a][b] = g[b][a] = true;
- }
- for (int i = 0; 2 * i <= n; ++i)
- build(i);
- cerr << masks.size() << endl;
- dp[0] = 1;
- forn (i, masks.size()) {
- int m = masks[i].second;
- if (dp.find(m) == dp.end()) continue;
- ll v = dp[m];
- if (m == (1 << n) - 1) {
- cout << v << endl;
- return 0;
- }
- int fr = 0;
- while (m & (1 << fr)) ++fr;
- int A = fr;
- for (int B = A + 1; B < n; ++B) {
- if (!(m & (1 << B)) && g[A][B]) {
- int mm = m | (1 << A) | (1 << B);
- dp[mm] += v;
- }
- }
- }
- cout << 0 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement