/*
Question:
When the length, width, and height of a doll are larger than the other, the small one can be put in and asked about
Minimum Number
Analysis:
Find the largest independent set, use the total number of dolls-the maximum match, and use two layers of loops to create a picture first. Every time the length, width, and height of a doll are larger than j hours,
Then g [I] [j] =
If it is true, you can create a graph. At the beginning, I first sorted it, and then I found that it was not needed... Direct
You can create a graph by repeating the two layers and then comparing them. Finding the maximum match is a pure hungy algorithm.
*/
# Include
<Iostream>
# Include
<Cstring>
# Include
<Cstdio>
Using namespace
Std;
# Define X 502
Int
Xm [X], ym [X], n, m;
Bool g [X] [X], use [X];
Struct node
{
Int a, B, c;
} P [X];
Bool dfs (int u)
{
For (int v = 1; v <= n; v ++)
If (g [u] [v] &! Use [v])
{
Use [v] = true;
If (ym [v] =-1 | dfs (ym [v])
{
Xm [u] = v;
Ym [v] = u;
Return true;
}
}
Return false;
}
Int hungry ()
{
Memset (xm,-1, sizeof (xm ));
Memset (ym,-1, sizeof (ym ));
Int ret = 0;
For (int u = 1; u <= n; u ++)
If (xm [u] =-1)
{
Memset (use, false, sizeof (use ));
If (dfs (u ))
Ret ++;
}
Return ret;
}
Int main ()
{
Freopen ("sum. in", "r", stdin );
Freopen ("sum. out", "w", stdout );
While (cin> n, n)
{
For (int I = 1; I <= n; I ++)
Scanf ("% d", & p [I]. a, & p [I]. B, & p [I]. c );
Memset (g, false, sizeof (g ));
For (int I = 1; I <= n; I ++) // create a graph
For (int j = 1; j <= n; j ++)
If (I! = J & p [j]. a> p [I]. a & p [j]. b> p [I]. B & p [j]. c> p [I]. c) // when all three conditions are met
G [j] [I] = true;
Printf ("% d \ n", n-hungry ());
}
Return 0;
}