Language: C++

#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
3 2
acp
ae
)");
#define cin input
#endif

bool bfs(int rGraph[202][202], int s, int t, int parent[])
{
    using namespace std;
    bool visited[202];
    memset(visited, 0, sizeof(visited));
    queue <int> q;
    q.push(s);
    visited[s] = true;
    parent[s] = -1;
 
    while (!q.empty())
    {
        int u = q.front();
        q.pop();
        for (int v = 0; v < 202; v++)
        {
            if (visited[v] == false && rGraph[u][v] > 0)
            {
                q.push(v);
                parent[v] = u;
                visited[v] = true;
            }
        }
    }
    return (visited[t] == true);
}
 
int fordFulkerson(int graph[202][202], int s, int t)
{
    int u, v;
    int rGraph[202][202];  
    for (u = 0; u < 202; u++)
    {
        for (v = 0; v < 202; v++)
        {
            rGraph[u][v] = graph[u][v];
        }
    }
    int parent[202];
    int max_flow = 0;
    while (bfs(rGraph, s, t, parent))
    {
        int path_flow = INT_MAX;
        for (v = t; v != s; v = parent[v])
        {
            u = parent[v];
            path_flow = min(path_flow, rGraph[u][v]);
        }
        for (v = t; v != s; v = parent[v])
        {
            u = parent[v];
            rGraph[u][v] -= path_flow;
            rGraph[v][u] += path_flow;
        }
        max_flow += path_flow;
    }
    return max_flow;
}

int main()
{
    int graph[202][202] = {}; 
	int h, w;
	cin >> h >> w;
    int xs, ys, xt, yt;
    REP (i, h)
    {
        string s;
        cin >> s;
        REP (j, w)
        {
            switch (s[j])
            {
            case 'o':
                graph[i][j + 100] = 1;
                graph[j + 100][i] = 1;
                break;
            case 'S':
                graph[200][j + 100] = 100000;
                graph[200][i] = 100000;
                xs = j;
                ys = i;
                break;
            case 'T':
                graph[i][201] = 100000;
                graph[j + 100][201] = 100000;
                xt = j;
                yt = j;
                break;
            }
        }
    }

    if (xs == xt || ys == yt)
        cout << -1 << endl;
    else
        cout << fordFulkerson(graph, 200, 201) << endl;

	return 0;
}


Compiler output:
a.cc: In function 'bool bfs(int (*)[202], int, int, int*)':
a.cc:37:5: error: 'memset' was not declared in this scope
   37 |     memset(visited, 0, sizeof(visited));
      |     ^~~~~~
a.cc:13:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   12 | #include <iomanip>
  +++ |+#include <cstring>
   13 | 
a.cc: In function 'int fordFulkerson(int (*)[202], int, int)':
a.cc:75:25: error: 'INT_MAX' was not declared in this scope
   75 |         int path_flow = INT_MAX;
      |                         ^~~~~~~
a.cc:13:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   12 | #include <iomanip>
  +++ |+#include <climits>
   13 |