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 int long long
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int h, w;
cin >> h >> w;
vector<string> v(h);
for (int i = 0; i < h;++i){
cin >> v[i];
}
vector<vector<int>> prefo(h, vector<int> (w));
vector<vector<int>> prefi(h, vector<int> (w));
for (int i = 0; i < w; ++i){
for (int j = 1; j < h; ++j){
if (v[j][i] == 'I')prefi[j][i] = prefi[j-1][i]+1;
else prefi[j][i] = prefi[j-1][i];
}
}
for (int i = 0; i < h; ++i){
for (int j = 1; j < w; ++j){
if (v[i][j] == 'O')prefo[i][j] = prefo[i][j-1]+1;
else prefo[i][j] = prefo[i][j-1];
}
}
int ans = 0;
for (int i = 0; i < h-1; ++i){
for (int j = 0; j < w-1; ++j){
if (v[i][j] == 'J'){
ans += (prefo[i][w-1]-prefo[i][j]) * (prefi[h-1][j] - prefi[i][j]);
}
}
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |