int f[maxn][maxn], g[maxn][maxn]; voidfloyd(){ for (int k = 1; k <= n; ++k) for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) { if (i == j || i == k || j == k) continue; f[i][j] = min(f[i][j], f[i][k] + f[k][j]); g[i][j] = max(g[i][j], g[i][k] + g[k][j]); } }
int s1, s2, s3; intmain(){ ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
cin >> n >> A >> B; for (int i = 1; i <= n; ++i) { char s[maxn]; cin >> s + 1; for (int j = 1; j <= n; ++j) if (s[j] == '+') g[i][j] = -2, f[i][j] = -1; elseif (s[j] == '-') g[i][j] = 1, f[i][j] = 2; elseif (s[j] == '?') g[i][j] = -2, f[i][j] = 2; else f[i][j] = g[i][j] = 0; } floyd(); for (int C = 1; C <= n; ++C) for (int D = C + 1; D <= n; ++D) { if (C == A || D == A || C == B || D == B) continue; if (g[C][A] > f[B][D] || g[D][A] > f[B][C]) ++s1; if (f[C][A] < g[B][D] || f[D][A] < g[B][C]) ++s3; if (f[C][A] == g[C][A] && f[B][D] == g[B][D] && f[C][A] == f[B][D]) ++s2; elseif (f[D][A] == g[D][A] && f[B][C] == g[B][C] && f[D][A] == f[B][C]) ++s2; } cout << s1 << " " << s2 << " " << s3 << "\n"; return0; }