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()
{
int h, w; cin >> h >> w;
vector<vector<char>> a(h, vector<char> (w));
for (int i = 0; i < h; i++){
string s; cin >> s;
for (int j = 0; j < w; j++){
a[i][j] = s[j];
}
}
vector<vector<int>> col(h, vector<int> (w));
vector<vector<int>> fil(h, vector<int> (w));
for (int i = 0; i < h; i++){
for (int j = 0; j < w; j++){
if (j == 0) fil[i][j] += (a[i][j] == 'O');
else {
fil[i][j] = (a[i][j] == 'O');
fil[i][j] += fil[i][j - 1];
}
}
}
for (int i = 0; i < w; i++){
for (int j = 0; j < h; j++){
if (j == 0)col[j][i] = (a[j][i] == 'I');
else {
col[j][i] = (a[j][i] == 'I');
col[j][i] += col[j-1][i];
}
}
}
int ans = 0;
for (int i = 0; i < h; i++){
for (int j = 0; j < w; j++){
if (a[i][j] == 'J') ans += (fil[i][w - 1] - fil[i][j]) * (col[h - 1][j] - col[i][j]);
}
}
cout << ans << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |