hiho week 170 register

Ended

Participants:224

Verdict:Accepted
Score:100 / 100
Submitted:2017-10-05 19:37:33

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 <iostream>
#include <cstring>
#define MAX_WORD 40
using namespace std;
int word_hash[MAX_WORD];
int word_cnt = 0;
int bfs(int hash, int depth, int count)
{
    if (depth == word_cnt)
        return count;
    int score = bfs(hash, depth + 1, count);
    if ((hash | word_hash[depth]) == hash + word_hash[depth])
    {
        int score2 = bfs(hash | word_hash[depth], depth+1, count +1);
        if (score2 > score)
            return score + 1;
    }
    return score;
}
int main()
{
    cin >> word_cnt;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX