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 ll long long
#define pii pair<int,int>
#define f first
#define s second
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int H, W;
cin>>H>>W;
vector<int> O[H];
vector<int> I[W];
vector<pii> J;
for(int i=0;i<H;i++) {
string s;
cin>>s;
for(int j=0;j<W;j++) {
if(s[j]=='O') O[i].push_back(j);
else if(s[j]=='I') I[j].push_back(i);
else J.push_back({i, j});
}
}
ll ans = 0;
for(pii j:J) {
ll o = O[j.f].end()-upper_bound(O[j.f].begin(), O[j.f].end(), j.s);
ll
i = I[j.s].end()-upper_bound(I[j.s].begin(), I[j.s].end(), j.f);
ans += i*o;
}
cout<<ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |