#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[i].begin(),row[i].end(),j)-row[i].begin();
int q=lower_bound(col[j].begin(),col[j].end(),i)-col[j].begin();
sol+=(ll)(row[i].size()-p)*(ll)(col[j].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 |
Correct |
1 ms |
512 KB |
Output is correct |
4 |
Correct |
1 ms |
512 KB |
Output is correct |
5 |
Correct |
2 ms |
888 KB |
Output is correct |
6 |
Correct |
2 ms |
876 KB |
Output is correct |
7 |
Correct |
2 ms |
748 KB |
Output is correct |
8 |
Correct |
2 ms |
784 KB |
Output is correct |
9 |
Correct |
2 ms |
748 KB |
Output is correct |
10 |
Correct |
2 ms |
748 KB |
Output is correct |
11 |
Correct |
2 ms |
876 KB |
Output is correct |
12 |
Correct |
2 ms |
748 KB |
Output is correct |
13 |
Correct |
2 ms |
748 KB |
Output is correct |
# |
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 |
Correct |
1 ms |
512 KB |
Output is correct |
4 |
Correct |
1 ms |
512 KB |
Output is correct |
5 |
Correct |
2 ms |
888 KB |
Output is correct |
6 |
Correct |
2 ms |
876 KB |
Output is correct |
7 |
Correct |
2 ms |
748 KB |
Output is correct |
8 |
Correct |
2 ms |
784 KB |
Output is correct |
9 |
Correct |
2 ms |
748 KB |
Output is correct |
10 |
Correct |
2 ms |
748 KB |
Output is correct |
11 |
Correct |
2 ms |
876 KB |
Output is correct |
12 |
Correct |
2 ms |
748 KB |
Output is correct |
13 |
Correct |
2 ms |
748 KB |
Output is correct |
14 |
Correct |
24 ms |
2976 KB |
Output is correct |
15 |
Correct |
2 ms |
1772 KB |
Output is correct |
16 |
Correct |
13 ms |
1772 KB |
Output is correct |
17 |
Correct |
1 ms |
492 KB |
Output is correct |
18 |
Correct |
32 ms |
3308 KB |
Output is correct |
19 |
Correct |
25 ms |
3436 KB |
Output is correct |
20 |
Correct |
23 ms |
2796 KB |
Output is correct |
21 |
Correct |
32 ms |
3308 KB |
Output is correct |
22 |
Correct |
25 ms |
3052 KB |
Output is correct |
23 |
Correct |
23 ms |
2924 KB |
Output is correct |
24 |
Correct |
32 ms |
3052 KB |
Output is correct |
25 |
Correct |
22 ms |
3308 KB |
Output is correct |
26 |
Correct |
23 ms |
2796 KB |
Output is correct |
# |
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 |
Correct |
1 ms |
512 KB |
Output is correct |
4 |
Correct |
1 ms |
512 KB |
Output is correct |
5 |
Correct |
2 ms |
888 KB |
Output is correct |
6 |
Correct |
2 ms |
876 KB |
Output is correct |
7 |
Correct |
2 ms |
748 KB |
Output is correct |
8 |
Correct |
2 ms |
784 KB |
Output is correct |
9 |
Correct |
2 ms |
748 KB |
Output is correct |
10 |
Correct |
2 ms |
748 KB |
Output is correct |
11 |
Correct |
2 ms |
876 KB |
Output is correct |
12 |
Correct |
2 ms |
748 KB |
Output is correct |
13 |
Correct |
2 ms |
748 KB |
Output is correct |
14 |
Correct |
24 ms |
2976 KB |
Output is correct |
15 |
Correct |
2 ms |
1772 KB |
Output is correct |
16 |
Correct |
13 ms |
1772 KB |
Output is correct |
17 |
Correct |
1 ms |
492 KB |
Output is correct |
18 |
Correct |
32 ms |
3308 KB |
Output is correct |
19 |
Correct |
25 ms |
3436 KB |
Output is correct |
20 |
Correct |
23 ms |
2796 KB |
Output is correct |
21 |
Correct |
32 ms |
3308 KB |
Output is correct |
22 |
Correct |
25 ms |
3052 KB |
Output is correct |
23 |
Correct |
23 ms |
2924 KB |
Output is correct |
24 |
Correct |
32 ms |
3052 KB |
Output is correct |
25 |
Correct |
22 ms |
3308 KB |
Output is correct |
26 |
Correct |
23 ms |
2796 KB |
Output is correct |
27 |
Execution timed out |
1093 ms |
49184 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |