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;
#define pii pair<int, int>
#define ff first
#define ss second
#define int long long
#define all(x) x.begin(), x.end()
const int maxn = 3e3 + 5;
int va[maxn];
char mtx[maxn][maxn];
int32_t main(){
int h, w; cin >> h >> w;
for(int i = 0; i < h; i++){
for(int j = 0; j < w; j++){
cin >> mtx[i][j];
}
}
int ans = 0;
for(int i = 0; i < w; i++){
for(int j = h-1; j >= 0; j--){
if(mtx[j][i]=='O') ans += va[j];
}
int ingots = 0;
for(int j = h-1; j >= 0; j--){
if(mtx[j][i]=='I') ingots++;
else if(mtx[j][i]=='J') va[j] += ingots;
}
}
cout << ans << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |