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;
using ll = long long;
void solve(){
int n,m;
cin>>n>>m;
vector<string>v(n);
for(string &i:v){
cin>>i;
}
vector<vector<int>>a(n);
vector<vector<int>>b(m);
for(int i = 0;i<n;i++){
for(int j = 0;j<m;j++){
if(v[i][j]=='O'){
a[i].push_back(j);
}
if(v[i][j]=='I'){
b[j].push_back(i);
}
}
}
ll ans = 0;
for(int i = 0;i<n;i++){
for(int j= 0;j<m;j++){
if(v[i][j]=='J'){
ll c = a[i].end()-upper_bound(a[i].begin(),a[i].end(),j);
ll d = b[j].end()-upper_bound(b[j].begin(),b[j].end(),i);
ans+=c*d;
}
}
}
cout<<ans<<endl;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(nullptr);
// ll t;cin>>t;while(t--)
solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |