Submission #1098162

#TimeUsernameProblemLanguageResultExecution timeMemory
1098162serifefedartarBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
188 ms163688 KiB
#include <bits/stdc++.h>
using namespace std;

#define fast ios::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
#define f first
#define s second
#define LOGN 21
const ll MOD = 1e9 + 7;
const ll MAXN = 3000 + 100;

#define int long long
vector<string> grid;
int toR[MAXN][MAXN], toD[MAXN][MAXN];

signed main() {
    fast;
    int H, W;
    cin >> H >> W;

    grid = vector<string>(H+1);
    for (int i = 1; i <= H; i++) {
        cin >> grid[i];
        grid[i] = "#" + grid[i];
    }

    for (int i = 1; i <= H; i++) {
        for (int j = W; j >= 1; j--)
            toR[i][j] = toR[i][j+1] + (grid[i][j] == 'O');
    }
    for (int i = 1; i <= W; i++) {
        for (int j = H; j >= 1; j--)
            toD[j][i] = toD[j+1][i] + (grid[j][i] == 'I');
    }

    int ans = 0;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (grid[i][j] == 'J')
                ans += toR[i][j] * toD[i][j];
        }
    }
    cout << ans << "\n";
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...