Submission #1364261

#TimeUsernameProblemLanguageResultExecution timeMemory
1364261iamhereforfunBitaro the Brave (JOI19_ho_t1)C++20
0 / 100
0 ms344 KiB
// Starcraft 2 enjoyer //

#include <bits/stdc++.h>

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")

using namespace std;

#define LSOne(X) ((X) & -(X))
#define int long long

const int N = 3e3 + 5;
const int M = 11;
const int B = 18;
const long long K = 2;
const int LG = 20;
const long long INF = 1e18 + 5;
const int P = 31;
const int MOD = 998244353;
const int nx[] = {0, 1, 0, -1}, ny[] = {-1, 0, 1, 0};

int h, w, pref[N][N], ans, cur;
char mp[N][N];

inline void solve()
{
    cin >> h >> w;
    for (int x = 1; x <= h; x++)
    {
        for (int y = 1; y <= w; y++)
        {
            cin >> mp[x][y];
            pref[x][y] = mp[x][y] == 'O';
            pref[x][y] += pref[x][y - 1];
        }
    }
    ans = cur = 0;
    for (int y = 1; y <= w; y++)
    {
        cur = 0;
        for (int x = h; x >= 1; x--)
        {
            if (mp[x][y] == 'J')
            {
                ans += cur * pref[x][w] - pref[x][y];
            }
            cur += mp[x][y] == 'I';
        }
    }
    cout << ans;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    for (int x = 1; x <= t; x++)
    {
        solve();
    }
    return 0;
}
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...