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;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int h, w;
cin >> h >> w;
vector<pair<int, int>> joia;
int orbes[h+1][w+1];
int ingots[h+1][w+1];
orbes[0][0] = 0;
ingots[0][0] = 0;
for (int i = 1; i <= h; i++)
{
for (int j = 1; j <= w; j++)
{
char x;
cin >> x;
if (x == 'J')
{
joia.push_back({i, j});
}
orbes[i][j] = orbes[i][j-1];
if (x == 'O')
{
orbes[i][j] += 1;
}
ingots[i][j] = ingots[i-1][j];
if (x == 'I')
{
ingots[i][j] += 1;
}
}
}
int ans = 0;
for (auto i : joia)
{
int a = orbes[i.first][w] - orbes[i.first][i.second];
int b = ingots[h][i.second] - ingots[i.first][i.second];
ans+=a*b;
}
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... |