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 endl "\n"
#define pii pair<int,int>
typedef long long int ll;
vector<pii> jj;
const int N=3005;
vector<int> o[N];
vector<int> l[N];
int main()
{
ios_base:: sync_with_stdio(false); cin.tie(0);
int n,m; cin>>n>>m;
for(int i=1; i<=n; i++) {
for(int j=1; j<=m; j++) {
char c;
cin>>c;
if(c=='J') jj.push_back({i,j});
else if(c=='O') o[i].push_back(j);
else if(c=='I') l[j].push_back(i);
}
}
ll lol=0;
for(auto a:jj) {
int f=a.first;
int s=a.second;
//cout<<f<<" "<<s<<endl;
/*for(int z:l[s]) {
cout<<z<<" "<<s<<endl;
}*/
int ans=o[f].end()-upper_bound(o[f].begin(),o[f].end(),s);
int anss=l[s].end()-upper_bound(l[s].begin(),l[s].end(),f);
//cout<<ans<<" "<<anss<<endl;
lol+=ans*anss;
//break;
}
cout<<lol<<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... |