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>
typedef long long ll;
#define pb push_back
#define MS(x,y) memset((x),(y),sizeof((x)))
#define MN 1000000007
using namespace std;
char mat[3001][3001];
ll oDesno[3001][3001];
ll iDole[3001][3001];
ll getO (ll i, ll j) {
if (j != 0) return oDesno[i][j-1];
else return 0;
}
ll getI (ll i, ll j) {
if (i != 0) return iDole[i-1][j];
else return 0;
}
int main()
{
#if LOCAL_DEBUG
fstream cin("in.txt");
#endif
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll n,m;
cin>>n>>m;
for (ll i = 0; i<n; i++) {
for (ll j = 0; j<m; j++) {
cin>>mat[i][j];
oDesno[i][j] = (mat[i][j] == 'O') + getO(i,j);
iDole[i][j] = (mat[i][j] == 'I') + getI(i,j);
}
}
ll res = 0;
for (ll i = 0; i<n; i++) {
for (ll j = 0; j<m; j++) {
if (mat[i][j] != 'J') continue;
res += (oDesno[i][m-1]-oDesno[i][j]) * (iDole[n-1][j]-iDole[i][j]);
}
}
cout<<res<<endl;
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... |