Submission #1085316

#TimeUsernameProblemLanguageResultExecution timeMemory
1085316ShaShiBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
152 ms88660 KiB
#include <bits/stdc++.h>
 
#define int long long
 
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
 
#define F first 
#define S second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define kill(x) cout << x << "\n", exit(0);
#define pii pair<int, int>
#define endl "\n"
 
 
 
using namespace std;
typedef long long ll;
// typedef __int128_t lll;
typedef long double ld;
 
const int MAXN = (int)3e3 + 7;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 + 7;


int n, m, k, tmp, t, tmp2, tmp3, tmp4, u, v, w, flag, q, ans, flag2;
char arr[MAXN][MAXN];
int ps[MAXN][MAXN];


int32_t main() {
    #ifdef LOCAL
    freopen("inp.in", "r", stdin);
    freopen("res.out", "w", stdout);
    #else
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #endif

    cin >> n >> m;

    for (int i=1; i<=n; i++) for (int j=1; j<=m; j++) cin >> arr[i][j];

    for (int i=1; i<=n; i++) {
        tmp = 0;

        for (int j=m; j>=1; j--) {
            tmp += (arr[i][j] == 'O');

            if (arr[i][j] == 'J') ps[i][j] += tmp;

            ps[i][j] += ps[i-1][j];

            if (arr[i][j] == 'I') ans += ps[i][j];
        }
    }
    
    cout << ans << endl;


    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...