After the analysis is performed by using the adjacent matrix at the beginning, it is found that O (n ^ 3) = 1500 ^ 3 must time out.
However, O (m * n) = 1500*15000 is enough for two seconds.
So I overwrite the wooden board and rewrite the binary chart... it's quite a sense of accomplishment... at least I can use the inefficient wooden board in the future.
I forgot my meaning... is to give you a tree, and ask the smallest point to cover all the sides... what tree-like DP do they use? I think I can do it too... but this question is completely bare for the Binary Graph board.
The graph is an undirected graph, so the final result is/2, which should easily prove that I will not repeat it.
The cardboard of the Bipartite Graph adjacent table is as follows:
[Cpp]
# Include <set>
# Include <map>
# Include <list>
# Include <cmath>
# Include <ctime>
# Include <deque>
# Include <queue>
# Include <stack>
# Include <bitset>
# Include <cstdio>
# Include <string>
# Include <vector>
# Include <cassert>
# Include <cstdlib>
# Include <cstring>
# Include <sstream>
# Include <fstream>
# Include <numeric>
# Include <iomanip>
# Include <iostream>
# Include <algorithm>
# Include <functional>
Using namespace std;
// Typedef long LL;
// Typedef _ int64 LL;
// Typedef long double DB;
// Typedef unisigned _ int64 LL;
// Typedef unsigned long ULL;
# Define EPS 1e-8
# Define maxn1600
# Define MAXE 300000
# Define INF 0x3f3f3f
# Define PI acos (-1.0)
// # Define MOD 99991.
// # Define MOD 99990001.
// # Define MOD 1000000007.
# Define max (a, B) (a)> (B )? (A) (B ))
# Define min (a, B) (a) <(B )? (A) (B ))
# Define max3 (a, B, c) (max (a, B), c ))
# Define min3 (a, B, c) (min (a, B), c ))
# Define mabs (a) (a <0 )? (-A):)
// # Define L (t) (t <1) // Left son t * 2
// # Define R (t) (t <1 | 1) // Right son t * 2 + 1
// # Define Mid (a, B) (a + B)> 1) // Get Mid
// # Define lowbit (a) (a &-a) // Get Lowbit
// Int gcd (int a, int B) {return B? Gcd (B, a % B): ;}
// Int lcm (int a, int B) {return a * B/gcd (a, B );}
Struct Edge
{
Int u, v, w; // Start Point End Point Weight
Int next;
} Edge [MAXE];
Int head [MAXN]; // edge of each vertex
Int cnt; // Number of Edges
Int n; // number of points
Int linker [MAXN]; // linker [v] = u indicates matching
Bool used [MAXN]; // whether to access
Void add (Edge x)
{
Edge [cnt]. u = x. u;
Edge [cnt]. v = x. v;
Edge [cnt]. w = x. w;
Edge [cnt]. next = head [x. u];
Head [x. u] = cnt ++;
Edge [cnt]. v = x. u;
Edge [cnt]. u = x. v;
Edge [cnt]. w = x. w;
Edge [cnt]. next = head [x. v];
Head [x. v] = cnt ++;
}
Bool dfs (int u)
{
For (int I = head [u]; I! =-1; I = edge [I]. next)
{
Int v = edge [I]. v;
If (! Used [v])
{
Used [v] = true;
If (linker [v] =-1 | dfs (linker [v])
{
Linker [v] = u;
Return true;
}
}
}
Return false;
}
Int hungary ()
{
Int res = 0;
Memset (linker,-1, sizeof (linker ));
For (int u = 0; u <n; u ++)
{
Memset (used, 0, sizeof (used ));
If (dfs (u ))
Res ++;
}
Return res;
}
Int main ()
{
// Freopen ("in.txt", "r", stdin );
// Freopen ("out.txt", "w", stdout );
While (scanf ("% d", & n )! = EOF)
{
Memset (edge, 0, sizeof (edge ));
Memset (head,-1, sizeof (head ));
Edge tmp;
Cnt = 0;
For (int I = 0; I <n; I ++)
{
Int a, B, c;
Scanf ("% d :( % d)", & a, & B );
While (B --)
{
Scanf ("% d", & c );
Tmp. u =;
Tmp. v = c;
Add (tmp );
}
}
Cout }
Return 0;
}
# Include <set>
# Include <map>
# Include <list>
# Include <cmath>
# Include <ctime>
# Include <deque>
# Include <queue>
# Include <stack>
# Include <bitset>
# Include <cstdio>
# Include <string>
# Include <vector>
# Include <cassert>
# Include <cstdlib>
# Include <cstring>
# Include <sstream>
# Include <fstream>
# Include <numeric>
# Include <iomanip>
# Include <iostream>
# Include <algorithm>
# Include <functional>
Using namespace std;
// Typedef long LL;
// Typedef _ int64 LL;
// Typedef long double DB;
// Typedef unisigned _ int64 LL;
// Typedef unsigned long ULL;
# Define EPS 1e-8
# Define maxn1600
# Define MAXE 300000
# Define INF 0x3f3f3f
# Define PI acos (-1.0)
// # Define MOD 99991.
// # Define MOD 99990001.
// # Define MOD 1000000007.
# Define max (a, B) (a)> (B )? (A) (B ))
# Define min (a, B) (a) <(B )? (A) (B ))
# Define max3 (a, B, c) (max (a, B), c ))
# Define min3 (a, B, c) (min (a, B), c ))
# Define mabs (a) (a <0 )? (-A):)
// # Define L (t) (t <1) // Left son t * 2
// # Define R (t) (t <1 | 1) // Right son t * 2 + 1
// # Define Mid (a, B) (a + B)> 1) // Get Mid
// # Define lowbit (a) (a &-a) // Get Lowbit
// Int gcd (int a, int B) {return B? Gcd (B, a % B): ;}
// Int lcm (int a, int B) {return a * B/gcd (a, B );}
Struct Edge
{
Int u, v, w; // Start Point End Point Weight
Int next;
} Edge [MAXE];
Int head [MAXN]; // edge of each vertex
Int cnt; // Number of Edges
Int n; // number of points
Int linker [MAXN]; // linker [v] = u indicates matching
Bool used [MAXN]; // whether to access
Void add (Edge x)
{
Edge [cnt]. u = x. u;
Edge [cnt]. v = x. v;
Edge [cnt]. w = x. w;
Edge [cnt]. next = head [x. u];
Head [x. u] = cnt ++;
Edge [cnt]. v = x. u;
Edge [cnt]. u = x. v;
Edge [cnt]. w = x. w;
Edge [cnt]. next = head [x. v];
Head [x. v] = cnt ++;
}
Bool dfs (int u)
{
For (int I = head [u]; I! =-1; I = edge [I]. next)
{
Int v = edge [I]. v;
If (! Used [v])
{
Used [v] = true;
If (linker [v] =-1 | dfs (linker [v])
{
Linker [v] = u;
Return true;
}
}
}
Return false;
}
Int hungary ()
{
Int res = 0;
Memset (linker,-1, sizeof (linker ));
For (int u = 0; u <n; u ++)
{
Memset (used, 0, sizeof (used ));
If (dfs (u ))
Res ++;
}
Return res;
}
Int main ()
{
// Freopen ("in.txt", "r", stdin );
// Freopen ("out.txt", "w", stdout );
While (scanf ("% d", & n )! = EOF)
{
Memset (edge, 0, sizeof (edge ));
Memset (head,-1, sizeof (head ));
Edge tmp;
Cnt = 0;
For (int I = 0; I <n; I ++)
{
Int a, B, c;
Scanf ("% d :( % d)", & a, & B );
While (B --)
{
Scanf ("% d", & c );
Tmp. u =;
Tmp. v = c;
Add (tmp );
}
}
Cout }
Return 0;
}