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>
#define int long long
#define endl '\n'
using namespace std;
const int N = 3001,INF=1e12;
char arr[N][N];
vector<pair<int,int>>jew;
vector<int>ob[N],col[N];
int32_t main()
{
//freopen("abc.in", "r", stdin);
int h , w;
cin >> h >> w;
for(int i = 0 ; i < h ; i ++){
for(int j = 0 ; j < w; j ++){
cin>>arr[i][j];
if(arr[i][j]=='J'){
jew.push_back({i,j});
}
else if(arr[i][j]=='O')
ob[i].push_back(j);
else if(arr[i][j]=='I'){
col[j].push_back(i);
}
}
}
int ans=0;
for(auto e : jew)
{
auto it = lower_bound(ob[e.first].begin(),ob[e.first].end(),e.second);
auto it2 = lower_bound(col[e.second].begin(),col[e.second].end(),e.first);
ans+=(ob[e.first].size()-(it-ob[e.first].begin())) * (col[e.second].size()-(it2-col[e.second].begin()));
}
cout<<ans<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |