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 <iostream>
#define ll long long
using namespace std;
int H, W;
string A[3001];
int hor[3001][3001], ver[3001][3001];
int main()
{
ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> H >> W;
for (int i = 0; i < H; i++) cin >> A[i];
for (int i = 0; i < H; i++)
{
for (int j = W - 1; j >= 0; j--)
{
hor[i][j] = (A[i][j] == 'O');
if (j + 1 < W) hor[i][j] += hor[i][j + 1];
}
}
for (int i = H - 1; i >= 0; i--)
{
for (int j = 0; j < W; j++)
{
ver[i][j] = (A[i][j] == 'I');
if (i + 1 < H) ver[i][j] += ver[i + 1][j];
}
}
ll res = 0;
for (int i = 0; i < H; i++)
{
for (int j = 0; j < W; j++)
{
res += 1ll * (A[i][j] == 'J') * hor[i][j] * ver[i][j];
}
}
cout << res << "\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... |