#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define fs first
#define sc second
#define pb push_back
void solve() {
int n,m;
cin>>n>>m;
string a[n];
for(int i=0;i<n;i++)cin>>a[i];
ll ans=0,c1[n+1][m+1],c2[n+1][m+1];
memset(c1,0,sizeof(c1));
memset(c2,0,sizeof(c2));
for(int i=n-1;i>-1;i--){
for(int j=m-1;j>-1;j--){
c1[i][j]=c1[i+1][j]+(a[i][j]=='I');
c2[i][j]=c2[i][j+1]+(a[i][j]=='O');
if(a[i][j]=='J')ans+=c1[i+1][j]*c2[i][j+1];
}
}
cout<<ans;
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
604 KB |
Output is correct |
11 |
Correct |
0 ms |
604 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
604 KB |
Output is correct |
11 |
Correct |
0 ms |
604 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
14 |
Correct |
3 ms |
3676 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
3 ms |
4444 KB |
Output is correct |
19 |
Correct |
2 ms |
4444 KB |
Output is correct |
20 |
Correct |
3 ms |
4440 KB |
Output is correct |
21 |
Correct |
3 ms |
4440 KB |
Output is correct |
22 |
Correct |
3 ms |
4444 KB |
Output is correct |
23 |
Correct |
3 ms |
4444 KB |
Output is correct |
24 |
Correct |
4 ms |
4444 KB |
Output is correct |
25 |
Correct |
3 ms |
4444 KB |
Output is correct |
26 |
Correct |
3 ms |
4444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
604 KB |
Output is correct |
11 |
Correct |
0 ms |
604 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
14 |
Correct |
3 ms |
3676 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
3 ms |
4444 KB |
Output is correct |
19 |
Correct |
2 ms |
4444 KB |
Output is correct |
20 |
Correct |
3 ms |
4440 KB |
Output is correct |
21 |
Correct |
3 ms |
4440 KB |
Output is correct |
22 |
Correct |
3 ms |
4444 KB |
Output is correct |
23 |
Correct |
3 ms |
4444 KB |
Output is correct |
24 |
Correct |
4 ms |
4444 KB |
Output is correct |
25 |
Correct |
3 ms |
4444 KB |
Output is correct |
26 |
Correct |
3 ms |
4444 KB |
Output is correct |
27 |
Correct |
106 ms |
142656 KB |
Output is correct |
28 |
Correct |
1 ms |
860 KB |
Output is correct |
29 |
Correct |
7 ms |
11184 KB |
Output is correct |
30 |
Correct |
0 ms |
860 KB |
Output is correct |
31 |
Correct |
81 ms |
105044 KB |
Output is correct |
32 |
Correct |
93 ms |
150096 KB |
Output is correct |
33 |
Correct |
97 ms |
150536 KB |
Output is correct |
34 |
Correct |
94 ms |
121684 KB |
Output is correct |
35 |
Correct |
90 ms |
150096 KB |
Output is correct |
36 |
Correct |
96 ms |
150672 KB |
Output is correct |
37 |
Correct |
117 ms |
151068 KB |
Output is correct |
38 |
Correct |
67 ms |
104048 KB |
Output is correct |
39 |
Correct |
71 ms |
104532 KB |
Output is correct |