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 cin(vec) for(auto& i : vec) cin >> i
#define cout(vec) for(auto& i : vec) cout << i << " "; cout << "\n";
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define loop(i,a,b) for (int i = a; i < b; i++)
#define F first
#define S second
#define pb(n) push_back(n)
#define pf(n) push_front(n)
#define dci(d) fixed<<setprecision(d)
#define sp ' '
#define el '\n'
#define all(v) v.begin(),v.end()
#define int long long
int dx[8]= {0,0,1,-1,-1,1,1,-1};
int dy[8]= {-1,1,0,0,-1,1,-1,1};
int const N=1e4+5,M=1e3+1,Mod=1e9+7;
void testcase(int h){
int n,m;cin>>n>>m;
char c[n][m];
map<char,vector<pair<int,int>>>loc;
for(int i=0;i<n;i++){
string s;cin>>s;
for(int j=0;j<m;j++){
c[i][j]=s[j];
}
}
int I[m]={};
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
I[j]+=c[i][j]=='I';
}
}
int o[n]={};
for(int j=0;j<m;j++){
for(int i=0;i<n;i++){
o[i]+=c[i][j]=='O';
}
}
// cout(I);cout(o);
int ans=0;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
o[i]-=c[i][j]=='O';
if(c[i][j]=='J'){
ans+=o[i]*I[j];
}
I[j]-=c[i][j]=='I';
}
}
cout<<ans<<el;
}
int32_t main()
{
// fast
testcase(1);
// int tc;cin>>tc;for(int i=1;i<=tc;i++)testcase(i);
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... |