Submission #1823226


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
int M;
map<LL,int>m;
vector<int>G2[101];
LL sh[50];

init(){
    sh[0]=1;
    REP(i,45){
        sh[i+1]=sh[i]*2;
    }
}


bool onbit(LL x,int y){
     if((x>>y)&1)return true;
     return false;
}

LL dfs(LL x,LL y){
   //cout<<x<<" "<<"a"<<endl;
   if(m[x]!=0){
      return m[x];
   }
   if((x==0)||y>=N)return 0;
   LL ans=0;
   if(!onbit(x,y)){
       // cout<<"a"<<x<<y<<endl;
        return dfs(x,y+1);
   }
   //cout<<"aa"<<x<<endl;
   x=(x^sh[y]);
   //cout<<"bb"<<x<<endl;
   ans=dfs(x,y+1);
   LL z=x;
   REP(i,G2[y].size()){
       if(onbit(z,G2[y][i])){
          z=(z^(LL)(sh[G2[y][i]]));
       }
   }
   ans=max(ans,dfs(z,y+1)+1);
   
   x=x|sh[y];
   m[x]=ans;
   //cout<<x<<" "<<ans<<endl;
   return ans;
}

int main(){
    init();
    cin>>N>>M;
    REP(i,M){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G2[a].push_back(b);
        G2[b].push_back(a);
    }
    LL x=0;
    REP(i,N){
        x=x|sh[i];
    }
    LL ans=dfs(x,0);
    cout<<ans<<endl;
    return(0);
}

Submission Info

Submission Time
Task G - Mixture Drug
User rapurasu
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1330 Byte
Status CE

Compile Error

./Main.cpp:14:6: error: ISO C++ forbids declaration of ‘init’ with no type [-fpermissive]
 init(){
      ^