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 ll long long
const ll MX = 3e3 + 5;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll h, w;
cin >> h >> w;
vector<vector<ll>> Ohere(MX, vector<ll>(MX, 0));
vector<vector<ll>> Ihere(MX, vector<ll>(MX, 0));
char tmp;
queue<pair<ll, ll>> q;
for (int i = 1; i <= h; i++)
{
for (int j = 1; j <= w; j++)
{
cin >> tmp;
if (tmp == 'J')
{
q.push({i, j});
}
else if (tmp == 'O')
{
Ohere[i][j]++;
}
else
{
Ihere[i][j]++;
}
Ohere[i][j] += Ohere[i][j - 1];
Ihere[i][j] += Ihere[i - 1][j];
}
}
ll ans = 0;
while (!q.empty())
{
ll x = q.front().first;
ll y = q.front().second;
q.pop();
ll Othere = Ohere[x][w] - Ohere[x][y - 1];
ll Ithere = Ihere[h][y] - Ihere[x - 1][y];
ans += Othere * Ithere;
}
// for (int i = 1; i <= h; i++)
// {
// for (int j = 1; j <= w; j++)
// {
// cout << Ohere[i][j];
// }
// cout << "\n";
// }
cout << ans;
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... |