题目描述
Problem Description
There are $ N $ types of chemicals, numbered from chemical $ 1 $ to chemical $ N $. You will mix one or more of these chemicals to create a new substance.
These chemicals are dangerous and can explode if mixed improperly.
For each integer $ i $ satisfying $1 \le i \le M$, if all three chemicals $ A_i, B_i, C_i $ are mixed, an explosion will occur. Otherwise, there will be no explosion.
You do not want to experience pain, so you will not mix them in a way that causes an immediate explosion. However, you want to create a substance as close to exploding as possible, so you aim to maximize the number of chemicals $ x $ such that adding chemical $ x $ to the substance would cause an explosion.
Find the maximum number of such chemicals.
Input Format
The input is given from the standard input in the following format:
$ N $ $ M $ $ A_1 $ $ B_1 $ $ C_1 $ $ A_2 $ $ B_2 $ $ C_2 $ $ A_3 $ $ B_3 $ $ C_3 $ $\hspace{25pt}\ \vdots$ $ A_M $ $ B_M $ $ C_M $
Output Format
Output the maximum number of chemicals that would cause an explosion if added to the substance.
Sample Input and Output
Sample Input #1
4 2
1 2 3
1 2 4
Sample Output #1
2
Sample Input #2
6 7
1 2 5
2 3 5
2 4 5
1 2 3
4 5 6
2 5 6
1 3 5
Sample Output #2
4
Sample Input #3
5 1
1 2 3
Sample Output #3
1
Notes/Hints
Constraints
- $3 \le N \le 14$
- $1 \le M \le \frac{N(N - 1)(N - 2)}{6}$
- $1 \le A_i < B_i < C_i \le N$
- $(A_i, B_i, C_i) \neq (A_j, B_j, C_j)$ for $i \neq j$
- All inputs are integers
Sample Explanation 1
If you mix chemicals $ 1 $ and $ 2 $, there will be no immediate explosion, and adding either chemical $ 3 $ or $ 4 $ will cause an explosion. Thus, the number of chemicals that would cause an explosion if added is $ 2 $. This number cannot be increased further, so the answer is $ 2 $.
Sample Explanation 2
If you mix chemicals $ 2 $ and $ 5 $, all chemicals $ 1, 3, 4, 6 $ will be the ones that would cause an explosion if added.
Sample Explanation 3
If you mix chemicals $ 1 $ and $ 2 $, adding chemical $ 3 $ will cause an explosion. Thus, the number of chemicals that would cause an explosion if added is $ 1 $.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分