#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
ll h,w;
string s[3005];
cin >> h >> w;
for(int i=0;i<h;i++) cin >> s[i];
unordered_map<ll,ll> rows;
unordered_map<ll,ll> colum;
unordered_map<ll,map<ll,ll>> rowsfin;
unordered_map<ll,map<ll,ll>> columfin;
for(int i=0;i<h;i++){
ll x=0;
for(int j=0;j<w;j++){
if(s[i][j]=='O') x++;
rowsfin[i][j+1]=x;
}
rows[i]=x;
// cout << i << " " << x << endl;
}
//cout << endl;
for(int i=0;i<w;i++){
ll x=0;
for(int j=0;j<h;j++){
if(s[j][i]=='I') x++;
columfin[i][j+1]=x;
}
colum[i]=x;
// cout << i << " " << x << endl;
}
ll ans=0;
for(ll i=0;i<h;i++){
for(ll j=0;j<w;j++){
if(s[i][j]=='J') ans+=((rows[i]-rowsfin[i][j])*(colum[j]-columfin[j][i]));
}
}
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
1772 KB |
Output is correct |
6 |
Correct |
3 ms |
1388 KB |
Output is correct |
7 |
Correct |
4 ms |
1644 KB |
Output is correct |
8 |
Correct |
4 ms |
1772 KB |
Output is correct |
9 |
Correct |
3 ms |
1388 KB |
Output is correct |
10 |
Correct |
4 ms |
1644 KB |
Output is correct |
11 |
Correct |
4 ms |
1772 KB |
Output is correct |
12 |
Correct |
4 ms |
1388 KB |
Output is correct |
13 |
Correct |
4 ms |
1644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
1772 KB |
Output is correct |
6 |
Correct |
3 ms |
1388 KB |
Output is correct |
7 |
Correct |
4 ms |
1644 KB |
Output is correct |
8 |
Correct |
4 ms |
1772 KB |
Output is correct |
9 |
Correct |
3 ms |
1388 KB |
Output is correct |
10 |
Correct |
4 ms |
1644 KB |
Output is correct |
11 |
Correct |
4 ms |
1772 KB |
Output is correct |
12 |
Correct |
4 ms |
1388 KB |
Output is correct |
13 |
Correct |
4 ms |
1644 KB |
Output is correct |
14 |
Correct |
99 ms |
24940 KB |
Output is correct |
15 |
Correct |
2 ms |
1004 KB |
Output is correct |
16 |
Correct |
63 ms |
17132 KB |
Output is correct |
17 |
Correct |
2 ms |
876 KB |
Output is correct |
18 |
Correct |
135 ms |
32620 KB |
Output is correct |
19 |
Correct |
106 ms |
31084 KB |
Output is correct |
20 |
Correct |
121 ms |
32128 KB |
Output is correct |
21 |
Correct |
149 ms |
32620 KB |
Output is correct |
22 |
Correct |
123 ms |
31084 KB |
Output is correct |
23 |
Correct |
111 ms |
31980 KB |
Output is correct |
24 |
Correct |
140 ms |
32620 KB |
Output is correct |
25 |
Correct |
107 ms |
31084 KB |
Output is correct |
26 |
Correct |
114 ms |
31980 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
1772 KB |
Output is correct |
6 |
Correct |
3 ms |
1388 KB |
Output is correct |
7 |
Correct |
4 ms |
1644 KB |
Output is correct |
8 |
Correct |
4 ms |
1772 KB |
Output is correct |
9 |
Correct |
3 ms |
1388 KB |
Output is correct |
10 |
Correct |
4 ms |
1644 KB |
Output is correct |
11 |
Correct |
4 ms |
1772 KB |
Output is correct |
12 |
Correct |
4 ms |
1388 KB |
Output is correct |
13 |
Correct |
4 ms |
1644 KB |
Output is correct |
14 |
Correct |
99 ms |
24940 KB |
Output is correct |
15 |
Correct |
2 ms |
1004 KB |
Output is correct |
16 |
Correct |
63 ms |
17132 KB |
Output is correct |
17 |
Correct |
2 ms |
876 KB |
Output is correct |
18 |
Correct |
135 ms |
32620 KB |
Output is correct |
19 |
Correct |
106 ms |
31084 KB |
Output is correct |
20 |
Correct |
121 ms |
32128 KB |
Output is correct |
21 |
Correct |
149 ms |
32620 KB |
Output is correct |
22 |
Correct |
123 ms |
31084 KB |
Output is correct |
23 |
Correct |
111 ms |
31980 KB |
Output is correct |
24 |
Correct |
140 ms |
32620 KB |
Output is correct |
25 |
Correct |
107 ms |
31084 KB |
Output is correct |
26 |
Correct |
114 ms |
31980 KB |
Output is correct |
27 |
Runtime error |
871 ms |
274436 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
28 |
Halted |
0 ms |
0 KB |
- |