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 N 3005
#define LL long long
#define pii pair<LL,LL>
LL h, w, ans;
char c;
LL o[N][N], i[N][N];
vector<pii> j;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> h >> w;
for (int x=1; x<=h; x++)
for (int y=1; y<=w; y++)
{
cin >> c;
if (c=='J') j.push_back({x,y});
o[x][y]=o[x][y-1]+(c=='O');
i[x][y]=i[x-1][y]+(c=='I');
}
ans=0;
for (auto now:j)
{
int a=now.first, b=now.second;
ans+=(o[a][w]-o[a][b])*(i[h][b]-i[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... |