#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include<bits/extc++.h>
//__gnu_pbds
int main(){
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int h,w;cin>>h>>w;
vector<string> grid(h);
for(int i=0;i<h;i++){
cin>>grid[i];
}
vector<vector<int> > sumO(h+1,vector<int>(w+1,0));
vector<vector<int> > sumI(h+1,vector<int>(w+1,0));
ll ans = 0;
for(int i=1;i<=h;i++){
for(int j=1;j<=w;j++){
sumO[i][j] = sumO[i][j-1]+(grid[i-1][j-1]=='O');
sumI[i][j] = sumI[i-1][j]+(grid[i-1][j-1]=='I');
}
}
for(int i=1;i<=h;i++){
for(int j=1;j<=w;j++){
if(grid[i-1][j-1]=='J') {
ans+=1LL*(sumO[i][w]-sumO[i][j])*(sumI[h][j]-sumI[i][j]);
}
}
}
cout<<ans<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
460 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
600 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
460 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
600 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
3 ms |
2292 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
1628 KB |
Output is correct |
17 |
Correct |
0 ms |
456 KB |
Output is correct |
18 |
Correct |
3 ms |
2908 KB |
Output is correct |
19 |
Correct |
2 ms |
2652 KB |
Output is correct |
20 |
Correct |
3 ms |
2928 KB |
Output is correct |
21 |
Correct |
3 ms |
2908 KB |
Output is correct |
22 |
Correct |
2 ms |
2908 KB |
Output is correct |
23 |
Correct |
3 ms |
2908 KB |
Output is correct |
24 |
Correct |
3 ms |
2908 KB |
Output is correct |
25 |
Correct |
2 ms |
2776 KB |
Output is correct |
26 |
Correct |
2 ms |
2908 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
460 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
600 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
3 ms |
2292 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
1628 KB |
Output is correct |
17 |
Correct |
0 ms |
456 KB |
Output is correct |
18 |
Correct |
3 ms |
2908 KB |
Output is correct |
19 |
Correct |
2 ms |
2652 KB |
Output is correct |
20 |
Correct |
3 ms |
2928 KB |
Output is correct |
21 |
Correct |
3 ms |
2908 KB |
Output is correct |
22 |
Correct |
2 ms |
2908 KB |
Output is correct |
23 |
Correct |
3 ms |
2908 KB |
Output is correct |
24 |
Correct |
3 ms |
2908 KB |
Output is correct |
25 |
Correct |
2 ms |
2776 KB |
Output is correct |
26 |
Correct |
2 ms |
2908 KB |
Output is correct |
27 |
Correct |
93 ms |
84556 KB |
Output is correct |
28 |
Correct |
1 ms |
860 KB |
Output is correct |
29 |
Correct |
5 ms |
6736 KB |
Output is correct |
30 |
Correct |
1 ms |
604 KB |
Output is correct |
31 |
Correct |
67 ms |
62412 KB |
Output is correct |
32 |
Correct |
70 ms |
88912 KB |
Output is correct |
33 |
Correct |
71 ms |
89424 KB |
Output is correct |
34 |
Correct |
77 ms |
72164 KB |
Output is correct |
35 |
Correct |
72 ms |
88912 KB |
Output is correct |
36 |
Correct |
73 ms |
89324 KB |
Output is correct |
37 |
Correct |
102 ms |
89684 KB |
Output is correct |
38 |
Correct |
50 ms |
61776 KB |
Output is correct |
39 |
Correct |
50 ms |
62108 KB |
Output is correct |