# [HEOI2016/TJOI2016]游戏

## Hint:

$n,m \le 50$

## Solution:

#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define ls p<<1
#define rs p<<1|1
using namespace std;
typedef long long ll;
const int mxn=1e5+5,inf=1e9;
int n,m,S,T,cnt,tot,ans,id1[55][55],id2[55][55],hd[mxn],cur[mxn],dep[mxn];
char a[55][55];

char c=getchar(); int x=0,f=1;
while(c>'9'||c<'0') {if(c=='-') f=-1;c=getchar();}
while(c<='9'&&c>='0') {x=(x<<3)+(x<<1)+(c&15);c=getchar();}
return x*f;
}
inline void chkmax(int &x,int y) {if(x<y) x=y;}
inline void chkmin(int &x,int y) {if(x>y) x=y;}

struct ed {
int to,nxt,w;
}t[mxn<<1];

inline void add(int u,int v,int w) {
t[cnt]=(ed) {v,hd[u],w}; hd[u]=cnt++;
t[cnt]=(ed) {u,hd[v],0}; hd[v]=cnt++;
}

int bfs() {
memset(dep,0,sizeof(dep));
queue<int > q; dep[S]=1;
q.push(S);
for(int i=0;i<=T;++i) cur[i]=hd[i];
while(!q.empty()) {
int u=q.front(); q.pop();
for(int i=hd[u];i!=-1;i=t[i].nxt) {
int v=t[i].to;
if(t[i].w>0&&!dep[v])
dep[v]=dep[u]+1,q.push(v);
}
}
return dep[T];
}

int dfs(int u,int f) {
if(u==T) return f;
for(int &i=cur[u];i!=-1;i=t[i].nxt) {
int v=t[i].to;
if(t[i].w>0&&dep[v]==dep[u]+1) {
int tp=dfs(v,min(t[i].w,f));
if(tp>0) {
t[i].w-=tp;
t[i^1].w+=tp;
return tp;
}
}
}
return 0;
}

void Dinic() {
while(bfs())
while(int tp=dfs(S,inf))
ans+=tp;
}

int get(int x,int y) {
return (x-1)*m+y;
}

int main()
{
for(int i=1;i<=n;++i)
for(int j=1;j<=m;++j)
cin>>a[i][j];
for(int i=1;i<=n;++i)
for(int j=1;j<=m;++j) {
if(a[i][j]=='#') continue ;
id1[i][j]=tot;
}
for(int j=1;j<=m;++j)
for(int i=1;i<=n;++i) {
if(a[i][j]=='#') continue ;