#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int nax=3e3+3;
char m[nax][nax];
vector<int> row[nax];
vector<int> col[nax];
int main(){
int h,w;
cin>>h>>w;
for(int i=0;i<h;i++)
for(int j=0;j<w;j++){
cin>>m[i][j];
if(m[i][j]=='O')row[i].push_back(j);
if(m[i][j]=='I')col[j].push_back(i);
}
ll sol=0;
for(int i=0;i<h;i++)
for(int j=0;j<w;j++){
if(m[i][j]=='J'){
int p=lower_bound(row[j].begin(),row[j].end(),i)-row[j].begin();
int q=lower_bound(col[i].begin(),col[i].end(),j)-col[i].begin();
sol+=(ll)(row[j].size()-p)*(ll)(col[i].size()-q);
}
}
cout<<sol<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
492 KB |
Output is correct |
3 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
492 KB |
Output is correct |
3 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
492 KB |
Output is correct |
3 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |