[Cpp]
/*
Maximum Flow Problems
Split points: Increase the super source points and sink points. The source points are connected to the food, and the weight of the edge is the largest number of foods. The drink is connected to the sink point, and the weight is the largest number of drinks;
Split people into two, one connected to food, and the other connected to drinks. The weight can be 1 or INF without any impact.
Connect the two split nodes. The Edge Weight is 1.
*/
# Include <cstdio>
# Include <cstring>
Const int nmax= 2007;
Const int INF = 0x3fffffff;
Int N, F, D;
Int NN;
Struct Adj
{
Int v, w;
Int next;
Adj (){}
Adj (int v, int w, int next): v (v), w (w), next (next ){}
} Adj [100 * nMax];
Int head [nMax];
Int cnt;
Int dis [nMax], num [nMax];
Void addEdge (int u, int v, int w)
{
Adj [cnt] = Adj (v, w, head [u]);
Head [u] = cnt ++;
Adj [cnt] = Adj (u, 0, head [v]);
Head [v] = cnt ++;
}
Int min (int a, int B)
{
Return a <B? A: B;
}
Int dfs (int u, int s, int d, int cost)
{
If (u = d) return cost;
Int I;
Int ans = 0;
Int _ min = NN;
For (I = head [u]; I! =-1; I = adj [I]. next)
{
Int v = adj [I]. v;
If (adj [I]. w)
{
If (dis [v] + 1 = dis [u])
{
Int t = dfs (v, s, d, min (adj [I]. w, cost ));
Adj [I]. w-= t;
Adj [I ^ 1]. w + = t;
Ans + = t;
Cost-= t;
If (dis [s] = NN) return ans;
If (! Cost) break;
}
If (_ min> dis [v])
_ Min = dis [v];
}
}
If (! Ans)
{
If (-- num [dis [u] = 0) dis [s] = NN;
Dis [u] = _ min + 1;
++ Num [dis [u];
}
Return ans;
}
Int isap (int s, int d)
{
Memset (dis, 0, sizeof (dis ));
Memset (num, 0, sizeof (num ));
Num [0] = NN;
Int ans = 0;
While (dis [s] <NN)
Ans + = dfs (s, s, d, INF );
Return ans;
}
Int main ()
{
// Freopen ("e: // data. in", "r", stdin );
While (scanf ("% d", & N, & F, & D )! = EOF)
{
Int I, j;
Int;
Char s [nMax];
Memset (head,-1, sizeof (head ));
Cnt = 0;
For (I = 1; I <= F; ++ I)
{
Scanf ("% d", & );
AddEdge (0, I, );
}
For (I = 1; I <= D; ++ I)
{
Scanf ("% d", & );
AddEdge (F + 2 * N + I, F + 2 * N + D + 1, );
}
For (I = 1; I <= N; ++ I)
{
AddEdge (F + I, F + N + I, 1 );
}
For (I = 1; I <= N; ++ I)
{
Scanf ("% s", s + 1 );
For (j = 1; j <= F; ++ j)
If (s [j] = 'y ')
AddEdge (j, F + I, INF );
}
For (I = 1; I <= N; ++ I)
{
Scanf ("% s", s + 1 );
For (j = 1; j <= D; ++ j)
If (s [j] = 'y ')
AddEdge (F + N + I, F + 2 * N + j, INF );
}
NN = F + 2 * N + D + 2;
Int ans = isap (0, NN-1 );
Printf ("% d \ n", ans );
}
Return 0;
}