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>
#define ll long long
using namespace std;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int H,W; cin >> H >> W;
vector<string> grid(H);
for(int i = 0;i<H;++i) cin >> grid[i];
vector<vector<int>> cntorbs(H,vector<int>(W,0)),cntingots(H,vector<int>(W,0));
for(int i = 0;i<H;++i){
int cnt = 0;
for(int j = W-1;j>=0;--j){
if(grid[i][j] == 'O') cnt++;
cntorbs[i][j] = cnt;
}
}
for(int i = 0;i<W;++i){
int cnt = 0;
for(int j = H-1;j>=0;--j){
if(grid[j][i] == 'I') cnt++;
cntingots[j][i] = cnt;
}
}
ll ans = 0;
for(int i = 0;i<H;++i){
for(int j = 0;j<W;++j){
if(grid[i][j] == 'J') ans += cntorbs[i][j]*cntingots[i][j];
}
}
cout << ans << "\n";
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... |