This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
///
/// breakdown breakdown
///
#include <bits/stdc++.h>
#define Loop(x,l,r) for(ll x = ll(l); x < ll(r); ++x)
#define LoopR(x,l,r) for(ll x = ll(r)-1; x >= ll(l); --x)
typedef long long ll;
using namespace std;
const int N = 3010;
char g[N][N];
ll O[N][N];
ll I[N][N];
int n, m;
int main()
{
ios::sync_with_stdio(false); cin.tie(0);
cin >> n >> m;
Loop(i,0,n)
{
Loop(j,0,m)
{
cin >> g[i][j];
if(g[i][j] == 'O') O[i][j]++;
if(g[i][j] == 'I') I[i][j]++;
}
}
Loop(i,0,n) LoopR(j,0,m-1)
O[i][j] += O[i][j+1];
LoopR(i,0,n-1) Loop(j,0,m)
I[i][j] += I[i+1][j];
ll ans = 0;
Loop(i,0,n) Loop(j,0,m)
if(g[i][j] == 'J')
ans += O[i][j]*I[i][j];
cout << ans << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |