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 ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pld pair<ld, ld>
#define pb push_back
#define fi first
#define se second
#define debug(x) cout << #x << " => " << x << endl
#define all(x) x.begin(),x.end()
int main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int n,m;cin>>n>>m;
string s[n];
for(int i=0;i<n;i++) cin>>s[i];
ll O[n],I[m];
memset(O,0,sizeof(O));
memset(I,0,sizeof(I));
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
if(s[i][j]=='O') O[i]++;
if(s[i][j]=='I') I[j]++;
}
}
ll ans=0;
for(int i=0;i<n;i++) for(int j=0;j<m;j++)
{
if(s[i][j]=='J') ans+=(O[i]*I[j]);
if(s[i][j]=='O') O[i]--;
if(s[i][j]=='I') I[j]--;
}
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... |