# Codeforces 11d-a Simple Task (pressure DP)

Source: Internet
Author: User

Test instructions

Figure out an N-point m-side graph to find the number of simple rings (no duplicate points and edges).

Ideas

This is a good question, this pressure DP save state is not a direct ring, but the number of paths. s represents a path, then Dp[s][i] indicates the number of rings with the minimum number of S as the starting point and I as the end point. Then we can determine whether the endpoint and the starting point are connected by enumerating the state, enumerating the starting point in the state and the end of the enumeration path.

Code
``#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <stack>#include <set>#include <map>#include <list>#include <string>#include <math.h>#include <stdlib.h>#include <time.h>using namespace STD;#define LL Long Long#define LOWBIT (x) ((x) & ( -X))#define Lson L, Mid, RT << 1#define Rson Mid + 1, R, RT << 1|1#define MP (A, B) Make_pair (A, b)Const intINF =0x3f3f3f3f;Const intMOD =1000000007;Const intMAXN =1e5+Ten;Const DoubleEPS =1e-8;Const DoublePI =ACOs(-1.0);typedefpair<int,int> PII; LL dp[1<< -][ -];BOOLa[ -][ -];intMain () {//freopen ("In.txt", "R", stdin);    //freopen ("OUT.txt", "w", stdout);    intN, M, U, v;Cin>> n >> m; for(inti =0; I < m; i++) {Cin>> u >> v;        U--, v--; A[U][V] = A[v][u] =1; }memset(DP,0,sizeof(DP)); for(inti =0; I < n; i++) dp[1<<i][i] =1; LL ans =0; for(ints =1; S < (1<< N); s++) {intSt =0; for(inti =0; I < n; i++)if(S & (1<< i)) st = i, i = n; for(inte = st; e < n; e++)if(S & (1<< e)) for(inti = st; I < n; i++)if(! (S & (1<< i)) && A[e][i]) {dp[s| (1<<i)][i] + = dp[s][e];if(A[i][st] && __builtin_popcount (s| (1<<i)) >=3) ans + = dp[s][e]; }    }cout<< ans/2<< Endl;return 0;}``

Codeforces 11d-a Simple Task (pressure DP)

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.