Language: C++

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
#define pb push_back
using namespace std;
const int maxn=210,inf=1e9;
int n,m,cnt=2,p[maxn],q[maxn];char s[maxn][maxn];
struct edge{int from,to,cap,flow;};
struct D{
    vector<edge> e;
    vector<int> G[maxn];
    int n,m,s,t,vis[maxn],d[maxn],cur[maxn];
    inline void add(int from,int to,int cap){
        e.pb((edge){from,to,cap,0});e.pb((edge){to,from,cap,0});
        m=e.size();G[from].pb(m-2);G[to].pb(m-1);
    }
    bool bfs(){
        memset(vis,0,sizeof(vis));memset(d,0,sizeof(d));o..o....So
        queue<int> q;q.push(s);vis[s]=1;
        while(!q.empty()){
            int u=q.front();q.pop();
            rep(i,0,(int)G[u].size()-1){
                edge &E=e[G[u][i]];
                if(!vis[E.to]&&E.cap>E.flow){
                    d[E.to]=d[u]+1;
                    q.push(E.to);
                    vis[E.to]=1;
                }
            }
        }
        return vis[t];
    }
    int dfs(int u,int a){
        if(u==t||a==0) return a;
        int flow=0,f;
        for(int &i=cur[u];i<G[u].size();++i){
            edge &E=e[G[u][i]];
            if(d[E.to]==d[u]+1&&(f=dfs(E.to,min(E.cap-E.flow,a)))){
             o..o....So
             o..o....So
             o..o....So
            }o..o....So
        }
        return flow;
    }
    int max_flow(int s,int t){
        this->s=s,this->t=t;
        int flow=0;
        while(bfs()){
            memset(cur,0,sizeof(cur));
            flow+=dfs(s,inf);
        }
        return flow;
    }
}D;
int main(){
    scanf("%d%d",&n,&m);int S=1,T=2;
    rep(i,1,n) rep(j,1,m){
        scanf(" %c",&s[i][j]);
        if(s[i][j]=='S'){
            if(p[i]||q[j]) return puts("-1"),0;
            p[i]=S,q[j]=S;
        }
        if(s[i][j]=='T'){
            if(p[i]||q[j]) return puts("-1"),0;
            p[i]=T,q[j]=T; 
        }
    }
    rep(i,1,n) if(!p[i]) p[i]=++cnt;
    rep(i,1,m) if(!q[i]) q[i]=++cnt;D.n=cnt;
    rep(i,1,n) rep(j,1,m) if(s[i][j]=='o') D.add(p[i],q[j],1);
    printf("%d\n",D.max_flow(S,T));
    return 0;
}

Compiler output:
a.cc: In member function 'bool D::bfs()':
a.cc:28:57: error: 'o' was not declared in this scope
   28 |         memset(vis,0,sizeof(vis));memset(d,0,sizeof(d));o..o....So
      |                                                         ^
a.cc:28:59: error: expected unqualified-id before '.' token
   28 |         memset(vis,0,sizeof(vis));memset(d,0,sizeof(d));o..o....So
      |                                                           ^
a.cc:29:24: error: request for member 'push' in 'q', which is of non-class type 'int [210]'
   29 |         queue<int> q;q.push(s);vis[s]=1;
      |                        ^~~~
a.cc:30:18: error: request for member 'empty' in 'q', which is of non-class type 'int [210]'
   30 |         while(!q.empty()){
      |                  ^~~~~
a.cc:31:21: error: request for member 'front' in 'q', which is of non-class type 'int [210]'
   31 |             int u=q.front();q.pop();
      |                     ^~~~~
a.cc:31:31: error: request for member 'pop' in 'q', which is of non-class type 'int [210]'
   31 |             int u=q.front();q.pop();
      |                               ^~~
a.cc:36:23: error: request for member 'push' in 'q', which is of non-class type 'int [210]'
   36 |                     q.push(E.to);
      |                       ^~~~
a.cc: In member function 'int D::dfs(int, int)':
a.cc:49:14: error: 'o' was not declared in this scope
   49 |              o..o....So
      |              ^
a.cc:49:16: error: expected unqualified-id before '.' token
   49 |              o..o....So
      |                ^
a.cc:52:14: error: 'o' was not declared in this scope
   52 |             }o..o....So
      |              ^
a.cc:52:16: error: expected unqualified-id before '.' token
   52 |             }o..o....So
      |                ^