hiho week 170 register

Ended

Participants:224

Verdict:Accepted
Score:100 / 100
Submitted:2017-10-07 10:09:55

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAX 43
using namespace std;
int n,word[MAX];
bool vis[MAX];
int dfs(int now,int state)
{
    int maxi=0;
    for(int nex=1;nex<=n;nex++)
    {
        if(vis[nex]) continue;
        if(state&word[nex]) continue;
        vis[nex]=1;
        maxi=max(maxi,dfs(nex,state|word[nex]));
        vis[nex]=0;
    }
    return now==0?maxi:maxi+1;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        char str[10];
        scanf("%s",&str);
        word[i]=0;
        for(int j=0;str[j];j++) word[i]|=1<<(str[j]-'a');
    }
    memset(vis,0,sizeof(vis));
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX