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 <iostream>
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define ll long long
#define pri pair<int,int>
#define prl pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pair<int,int>>
#define vpl vector<pair<ll,ll>>
#define re return 0
#define sqrt sqrtl
int32_t main() {
int h,w;cin>>h>>w;
vector<vector<int>> no(h,vector<int>(w));
vector<vector<int>> ni(w,vector<int>(h));
vector<string> grid(h);
for (int i = 0;i<h;i++) {
string s;cin>>s;
for (int j = 0;j<w;j++) {
if (j==0) no[i][j] = (s[j]=='O');
else no[i][j] = no[i][j-1] + (s[j]=='O');
if (i==0) ni[j][i] = (s[j]=='I');
else ni[j][i] = ni[j][i-1]+(s[j]=='I');
}
grid[i] = s;
}
int s = 0;
for (int i = 0;i<h;i++) {
for (int j = 0;j<w;j++) {
if (grid[i][j]!='J') continue;
s+= (no[i][w-1] - no[i][j]) * (ni[j][h-1] - ni[j][i]);
//cout<<no[i][j]<<" ";
}//cout<<endl;
}
cout<<s<<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... |