This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int MAXH = 3000;
string v[MAXH];
int ingots[MAXH];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int h, w, i, j, orbs;
    long long ans;  
    cin >> h >> w;
    for(i = 0; i < h; i++){
        cin >> v[i];
    }
    ans = 0;
    for(i = h - 1; i >= 0; i--){
        orbs = 0;
        for(j = w - 1; j >= 0; j--){
            switch(v[i][j]){
                case 'O':
                    ++orbs;
                    break;
                case 'I':
                    ++ingots[j];
                    break;
                case 'J':
                    ans += 1LL * orbs * ingots[j];
                    break;
            }
        }
    }
    cout << ans;
    return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |