1217 – Neighbor House (II)

Problem Link : http://lightoj.com:81/volume/problem/1217


#include <bits/stdc++.h>

#define pii              pair <int,int>
#define pll              pair <long long,long long>
#define sc               scanf
#define pf               printf
#define Pi               2*acos(0.0)
#define ms(a,b)          memset(a, b, sizeof(a))
#define pb(a)            push_back(a)
#define MP               make_pair
#define db               double
#define ll               long long
#define EPS              10E-10
#define ff               first
#define ss               second
#define sqr(x)           (x)*(x)
#define D(x)             cout<<#x " = "<<(x)<<endl
#define VI               vector <int>
#define DBG              pf("Hi\n")
#define MOD              1000000007
#define CIN              ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define SZ(a)            (int)a.size()
#define sf(a)            scanf("%d",&a)
#define sfl(a)           scanf("%lld",&a)
#define sff(a,b)         scanf("%d %d",&a,&b)
#define sffl(a,b)        scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)      scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)     scanf("%lld %lld %lld",&a,&b,&c)
#define stlloop(v)       for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define REP(i,a,b)       for(int i=a;i<b;i++)
#define RREP(i,a,b)      for(int i=a;i>=b;i--)
#define TEST_CASE(t)     for(int z=1;z<=t;z++)
#define PRINT_CASE       printf("Case %d: ",z)
#define LINE_PRINT_CASE  printf("Case %d:\n",z)
#define CASE_PRINT       cout<<"Case "<<z<<": "
#define all(a)           a.begin(),a.end()
#define intlim           2147483648
#define infinity         (1<<28)
#define ull              unsigned long long
#define gcd(a, b)        __gcd(a, b)
#define lcm(a, b)        ((a)*((b)/gcd(a,b)))

using namespace std;


/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N | (1<<pos);}
//int reset(int N,int pos){return N= N & ~(1<<pos);}
//bool check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/

int n;
int ara[1001];

int    dp[1001][1001][3];
bool xxxxx[1001][1001][3];
int yy=1;

int func(int idx, int last, int state)
{

    if(idx>n)
    {
        if(state==0 && last!=n)
            return ara[1];
        return 0;
    }

    int &ret=dp[idx][last][state];
    bool &cas=xxxxx[idx][last][state];
    if(cas) return ret;
    cas=1;

////    if(ret!=-1) return ret;

    int p=0,q=0;

    if(idx==1)
    {
        p=ara[1]+func(idx+2,idx,1);
        q=func(idx+1,last,state);
    }
    else if(idx==2)
    {
        p=ara[2]+func(idx+2,idx,2);
        q=func(idx+1,0,state);
    }
    else if(idx==n)
    {
        if(last!=n-1 && state!=1)
            p=ara[n]+func(idx+2,idx,state);
        q=func(idx+1,last,state);
    }
    else
    {
        p=ara[idx]+func(idx+2,idx,state);
        q=func(idx+1,last,state);
    }

    return ret=max(p,q);


}

int main()
{

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    int t;
    sf(t);
    TEST_CASE(t)
    {
        sf(n);
        for(int i=1; i<=n; i++) sf(ara[i]);
//        ms(dp,-1);
//        yy++;
        ms(xxxxx,0);
        PRINT_CASE;
        printf("%d\n",func(1,0,0));

    }

    return 0;
}

Advertisements

Light OJ 1013 – Love Calculator

Problem Link : http://www.lightoj.com/volume_showproblem.php?problem=1013


/*
         +-+ +-+ +-+
         |R| |.| |S|
         +-+ +-+ +-+
 */

#include <bits/stdc++.h>

#define pii             pair <int,int>
#define sc              scanf
#define pf              printf
#define Pi              2*acos(0.0)
#define ms(a,b)         memset(a, b, sizeof(a))
#define pb(a)           push_back(a)
#define MP              make_pair
#define db              double
#define ll              long long
#define EPS             10E-10
#define ff              first
#define ss              second
#define sqr(x)          (x)*(x)
#define D(x)            cout<<#x " = "<<(x)<<endl
#define VI              vector <int>
#define DBG             pf("Hi\n")
#define MOD             100007
#define MAX             10000
#define CIN             ios_base::sync_with_stdio(0); cin.tie(0)
#define SZ(a)           (int)a.size()
#define sf(a)           scanf("%d",&a)
#define sfl(a)          scanf("%lld",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sffl(a,b)       scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)    scanf("%lld %lld %lld",&a,&b,&c)
#define loop(i,n)       for(int i=0;i<n;i++)
#define REP(i,a,b)      for(int i=a;i<b;i++)
#define TEST_CASE(t)    for(int z=1;z<=t;z++)
#define PRINT_CASE      printf("Case %d: ",z)
#define all(a)          a.begin(),a.end()
#define intlim          2147483648
#define inf             1000000
#define ull             unsigned long long

using namespace std;


/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N | (1<<pos);}
//int reset(int N,int pos){return N= N & ~(1<<pos);}
//bool check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/

string s1,s2;

int dp[35][35];
ll dp2[35][35][65];

int sz1,sz2,len;

int LCS(int i, int j)
{
    if(i>=sz1 || j>=sz2) return 0;

    int &ret=dp[i][j];
    if(ret!=-1) return ret;

    ret=0;

    if(s1[i]==s2[j])
    {
        ret=1+LCS(i+1,j+1);
    }
    else
        ret=max(LCS(i+1,j),LCS(i,j+1));
    return ret;

}

ll cnt_str(int i, int j, int l)
{
        if(i>=sz1)
        {
            l+=sz2-j;
            if(l==len) return 1;
            else return 0;
        }

        if(j>=sz2)
        {
            l+=sz1-i;
            if(l==len) return 1;
            else return 0;
        }

        ll &ret= dp2[i][j][l];
        if(ret!=-1) return ret;
        ret=0;

        if(s1[i]==s2[j])
        {
            ret=cnt_str(i+1,j+1,l+1);
        }
        else
        {
            ret+=cnt_str(i+1,j,l+1);
            ret+=cnt_str(i,j+1,l+1);
        }
    return ret;
}

int main()
{
//    freopen("in.txt","r",stdin);
    ///freopen("out.txt","w",stdout);
    CIN;
    int t;
    cin>>t;
    TEST_CASE(t)
    {
        cin>>s1>>s2;
        sz1=SZ(s1);
        sz2=SZ(s2);

        cout<<"Case "<<z<<": ";
        ms(dp,-1);
        ms(dp2,-1);
        len=sz1+sz2-LCS(0,0);
        cout<<len<<" ";
        cout<<cnt_str(0,0,0)<<endl;

    }
    return 0;
}


Light OJ 1025 – The Specials Menu

Problem Link : http://www.lightoj.com/volume_showproblem.php?problem=1025


/*
         +-+ +-+ +-+
         |R| |.| |S|
         +-+ +-+ +-+
 */

#include <bits/stdc++.h>

#define pii             pair <int,int>
#define sc              scanf
#define pf              printf
#define Pi              2*acos(0.0)
#define ms(a,b)         memset(a, b, sizeof(a))
#define pb(a)           push_back(a)
#define MP              make_pair
#define db              double
#define ll              long long
#define EPS             10E-10
#define ff              first
#define ss              second
#define sqr(x)          (x)*(x)
#define D(x)            cout<<#x " = "<<(x)<<endl
#define VI              vector <int>
#define DBG             pf("Hi\n")
#define MOD             100007
#define MAX             10000
#define CIN             ios_base::sync_with_stdio(0); cin.tie(0)
#define SZ(a)           (int)a.size()
#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d%d",&a,&b)
#define sfff(a,b,c)     scanf("%d%d%d",&a,&b,&c)
#define loop(i,n)       for(int i=0;i<n;i++)
#define REP(i,a,b)      for(int i=a;i<b;i++)
#define TEST_CASE(t)    for(int z=1;z<=t;z++)
#define PRINT_CASE      printf("Case %d: ",z)
#define all(a)          a.begin(),a.end()
#define intlim          2147483648
#define inf             1000000
#define ull             unsigned long long

using namespace std;


/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N | (1<<pos);}
//int reset(int N,int pos){return N= N & ~(1<<pos);}
//bool check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/

ll dp[70][70];
string str;

ll func(int i, int j)
{
    if(i==j) return 1;
    if(i>j) return 0;
    ll &ret=dp[i][j];
    if(ret!=-1) return ret;
    ll ans=0,a=0,b=0;
    if(str[i]==str[j])
        ans=1+func(i+1,j)+func(i,j-1);
    else
        ans=func(i+1,j)+func(i,j-1)-func(i+1,j-1);

    return ret=ans;
}

int main()
{
    ///freopen("in.txt","r",stdin);
    ///freopen("out.txt","w",stdout);
    int t;
    sf(t);
    TEST_CASE(t)
    {

        cin>>str;
        ms(dp,-1);
        PRINT_CASE;
        cout<<func(0,SZ(str)-1)<<endl;
    }
    return 0;
}

UVa 825 – Walking on the Safe Side


/*
User ID: turing_13
Link: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=766
*/

/*
         +-+ +-+ +-+
         |R| |.| |S|
         +-+ +-+ +-+
 */

#include <bits/stdc++.h>

#define pii             pair <int,int>
#define sc              scanf
#define pf              printf
#define Pi              2*acos(0.0)
#define ms(a,b)         memset(a, b, sizeof(a))
#define pb(a)           push_back(a)
#define MP              make_pair
#define db              double
#define ll              long long
#define EPS             10E-10
#define ff              first
#define ss              second
#define sqr(x)          (x)*(x)
#define D(x)            cout<<#x " = "<<(x)<<endl
#define VI              vector <int>
#define DBG             pf("Hi\n")
#define MOD             100007
#define MAX             10000
#define CIN             ios_base::sync_with_stdio(0); cin.tie(0)
#define SZ(a)           (int)a.size()
#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d%d",&a,&b)
#define sfff(a,b,c)     scanf("%d%d%d",&a,&b,&c)
#define loop(i,n)       for(int i=0;i<n;i++)
#define REP(i,a,b)      for(int i=a;i<b;i++)
#define TEST_CASE(t)    for(int z=1;z<=t;z++)
#define PRINT_CASE      printf("Case %d: ",z)
#define all(a)          a.begin(),a.end()
#define intlim          2147483648
#define inf             1000000
#define ull             unsigned long long

using namespace std;


/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

ll dp[500][500];
int n,m;

ll func(int i, int j)
{
    if(i==n-1 && j==m-1) return 1;
    if(i==n || j==m) return 0;
    ll &ret=dp[i][j];
    if(ret!=-1) return ret;
    ll ans1=0;
    ans1+=func(i,j+1);
    ans1+=func(i+1,j);
    return ret= ans1;
}

void allclear()
{
    loop(i,n+3)loop(j,m+3)
    {
        dp[i][j]=-1;
    }
}

int main()
{
    ///freopen("in.txt","r",stdin);
    ///freopen("out.txt","w",stdout);
    int t;
    sf(t);
    while(t--)
    {
        sff(m,n);
        allclear();
        string str;
        vector<int>v;
        getchar();
        loop(i,m)
        {
            getline(cin,str);
            stringstream ss(str);
            int num;
            while(ss>>num)
            {
                v.pb(num);
            }
            REP(i,1,SZ(v))
            {
                dp[v[i]-1][v[0]-1]=0;
            }
            ss.clear();
            v.clear();
        }

        pf("%lld\n",func(0,0));
        if(t)
            pf("\n");
    }
    return 0;
}


Light OJ 1033 – Generating Palindromes

Problem Link : http://www.lightoj.com/volume_showproblem.php?problem=1033


/*
         +-+ +-+ +-+
         |R| |.| |S|
         +-+ +-+ +-+
 */

#include <bits/stdc++.h>

#define pii             pair <int,int>
#define sc              scanf
#define pf              printf
#define Pi              2*acos(0.0)
#define ms(a,b)         memset(a, b, sizeof(a))
#define pb(a)           push_back(a)
#define MP              make_pair
#define db              double
#define ll              long long
#define EPS             10E-10
#define ff              first
#define ss              second
#define sqr(x)          (x)*(x)
#define D(x)            cout<<#x " = "<<(x)<<endl
#define VI              vector <int>
#define DBG             pf("Hi\n")
#define MOD             100007
#define MAX             10000
#define CIN             ios_base::sync_with_stdio(0); cin.tie(0)
#define SZ(a)           (int)a.size()
#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d%d",&a,&b)
#define sfff(a,b,c)     scanf("%d%d%d",&a,&b,&c)
#define loop(i,n)       for(int i=0;i<n;i++)
#define REP(i,a,b)      for(int i=a;i<b;i++)
#define TEST_CASE(t)    for(int z=1;z<=t;z++)
#define PRINT_CASE      printf("Case %d: ",z)
#define all(a)          a.begin(),a.end()
#define intlim          2147483648
#define inf             1000000
#define ull             unsigned long long

using namespace std;


/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

/*-----------------------Bitmask------------------*/
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/

int dp[102][102];
string str;
int len;
int func(int i, int j)
{
    if(i>=len || j<0 || j<i) return 0;
    int &ret=dp[i][j];
    if(ret!=-1) return ret;
    int ans=0;
    if(str[i]==str[j])
    {
        ans=func(i+1,j-1);
    }
    else
    {
        ans=min(1+func(i,j-1),1+func(i+1,j));
    }
    return ret=ans;
}

int main()
{
    ///freopen("in.txt","r",stdin);
    ///freopen("out.txt","w",stdout);

    int t;
    sf(t);
    TEST_CASE(t)
    {
        cin>>str;
        ms(dp,-1);
        len=SZ(str);
        PRINT_CASE;
        pf("%d\n",func(0,len-1));
        str.clear();
    }

    return 0;
}

Light OJ : 1110 – An Easy LCS

2

Problem Link : http://www.lightoj.com/volume_showproblem.php?problem=1110



/*
         +-+ +-+ +-+
         |R| |.| |S|
         +-+ +-+ +-+
 */

#include <bits/stdc++.h>

#define pii             pair <int,int>
#define sc              scanf
#define pf              printf
#define Pi              2*acos(0.0)
#define ms(a,b)         memset(a, b, sizeof(a))
#define pb(a)           push_back(a)
#define MP              make_pair
#define db              double
#define ll              long long
#define EPS             10E-10
#define ff              first
#define ss              second
#define sqr(x)          (x)*(x)
#define D(x)            cout<<#x " = "<<(x)<<endl
#define VI              vector <int>
#define DBG             pf("Hi\n")
#define MOD             100007
#define MAX             10000
#define CIN             ios_base::sync_with_stdio(0); cin.tie(0)
#define SZ(a)           (int)a.size()
#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d%d",&a,&b)
#define sfff(a,b,c)     scanf("%d%d%d",&a,&b,&c)
#define loop(i,n)       for(int i=0;i<n;i++)
#define REP(i,a,b)      for(int i=a;i<b;i++)
#define TEST_CASE(t)    for(int z=1;z<=t;z++)
#define PRINT_CASE      printf("Case %d: ",z)
#define all(a)          a.begin(),a.end()
#define intlim          2147483648
#define inf             1000000
#define ull             unsigned long long

using namespace std;


/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

/*-----------------------Bitmask------------------*/
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/

char s1[105],s2[105];
int dp[105][105];
string ans[105][105];
int n,m;

void LCS()
{
    loop(i,n+2)
    {
        dp[i][0]=0;
        ans[i][0]="";
    }
    loop(i,m+2)
    {
        dp[0][i]=0;
        ans[0][i]="";
    }

    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
    {
        if(s1[i-1]==s2[j-1])
        {
            dp[i][j]=dp[i-1][j-1]+1;
            ans[i][j]=ans[i-1][j-1]+s1[i-1];
        }
        else if(dp[i-1][j]>dp[i][j-1])
        {
            dp[i][j]=dp[i-1][j];
            ans[i][j]=ans[i-1][j];
        }
        else if(dp[i][j-1]>dp[i-1][j])
        {
            dp[i][j]=dp[i][j-1];
            ans[i][j]=ans[i][j-1];
        }
        else
        {
            dp[i][j]=dp[i-1][j];
            ans[i][j]=min(ans[i-1][j],ans[i][j-1]);
        }
    }
}

int main()
{
    ///freopen("in.txt","r",stdin);
    ///freopen("out.txt","w",stdout);
    int t;
    sf(t);
    TEST_CASE(t)
    {
        getchar();
        sc("%s %s",s1,s2);
        n=strlen(s1);
        m=strlen(s2);
        LCS();
        PRINT_CASE;
        if(dp[n][m]==0)
            pf(":(\n");
        else
            cout<<ans[n][m]<<endl;
    }
    return 0;
}

Light OJ : 1406 – Assassin`s Creed

Problem Link : http://www.lightoj.com/volume_showproblem.php?problem=1406


/*
         +-+ +-+ +-+
         |R| |.| |S|
         +-+ +-+ +-+
 */

#include <bits/stdc++.h>

#define pii             pair <int,int>
#define sc              scanf
#define pf              printf
#define Pi              2*acos(0.0)
#define ms(a,b)         memset(a, b, sizeof(a))
#define pb(a)           push_back(a)
#define MP              make_pair
#define db              double
#define ll              long long
#define EPS             10E-10
#define ff              first
#define ss              second
#define sqr(x)          (x)*(x)
#define D(x)            cout<<#x " = "<<(x)<<endl
#define VI              vector <int>
#define DBG             pf("Hi\n")
#define MOD             100007
#define MAX             10000
#define CIN             ios_base::sync_with_stdio(0); cin.tie(0)
#define SZ(a)           (int)a.size()
#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d%d",&a,&b)
#define sfff(a,b,c)     scanf("%d%d%d",&a,&b,&c)
#define loop(i,n)       for(int i=0;i<n;i++)
#define REP(i,a,b)      for(int i=a;i<b;i++)
#define TEST_CASE(t)    for(int z=1;z<=t;z++)
#define PRINT_CASE      printf("Case %d: ",z)
#define all(a)          a.begin(),a.end()
#define intlim          2147483648
#define inf             1000000
#define ull             unsigned long long


using namespace std;

vector<int>graph[16];
bool visited[16][1<<16];
bool check_vis[1<<16];
int dp[1<<16];
int n,m;

void dfs(int u, int mask)
{
    visited[u][mask]=1;
    check_vis[mask]=1;
    loop(i,SZ(graph[u]))
    {
        int v=graph[u][i];
        if(!visited[v][mask|(1<<v)])
            dfs(v,mask|(1<<v));
    }
}

void allclear()
{
    loop(i,n+1)
    {
        graph[i].clear();
    }
    ms(visited,0);
    ms(check_vis,0);
    ms(dp,-1);
}

int dp_func(int mask)
{
    int &ret = dp[mask];
    if(mask==0) return 0;
    if(ret!=-1) return ret;
    ret=100;
    for(int i=mask; i>0; i=mask & (i-1))
    {
        if(check_vis[i])
        {
            ret=min(ret,1+dp_func(mask^i)); // XOR for remaining unvisited node
        }
    }
    return ret;
}

int main()
{
    ///freopen("in.txt","r",stdin);
   ///freopen("out.txt","w",stdout);
    int t,a,b;
    sf(t);
    TEST_CASE(t)
    {
        sff(n,m);
        allclear();
        loop(i,m)
        {
            sff(a,b);
            a--,b--;
            graph[a].pb(b);
        }

        loop(i,n)
        {
            dfs(i,1<<i);
        }
        PRINT_CASE;
        cout<<dp_func((1<<n)-1)<<endl;
    }
    return 0;
}