#include<bits/stdc++.h>
using namespace std;
#define int long long int
int n , m , ao[3005][3005] , ai[3005][3005] , sum;
char a[3005][3005] ;
int32_t main()
{
ios_base::sync_with_stdio(0);cin.tie(0);
cin >> n >> m;
for(int i=0 ; i<n ; i++)
{
for(int j=0 ; j<m ; j++)
{
cin >> a[i][j];
if(a[i][j]=='O')ao[i][j]++;
if(a[i][j]=='I')ai[i][j]++;
}
}
for(int i=n-1 ; i>=0 ; i--)for(int j=m-1 ; j>=0 ; j--)ao[i][j]+=ao[i][j+1] , ai[i][j]+=ai[i+1][j];
for(int i=n-1 ; i>=0 ; i--)for(int j=m-1 ; j>=0 ; j--)if(a[i][j]=='J')sum += ao[i][j] * ai[i][j];
cout << sum;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4560 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4440 KB |
Output is correct |
5 |
Correct |
2 ms |
10844 KB |
Output is correct |
6 |
Correct |
2 ms |
10844 KB |
Output is correct |
7 |
Correct |
2 ms |
10672 KB |
Output is correct |
8 |
Correct |
2 ms |
10844 KB |
Output is correct |
9 |
Correct |
2 ms |
10844 KB |
Output is correct |
10 |
Correct |
2 ms |
10844 KB |
Output is correct |
11 |
Correct |
2 ms |
10720 KB |
Output is correct |
12 |
Correct |
2 ms |
10844 KB |
Output is correct |
13 |
Correct |
2 ms |
10844 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4560 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4440 KB |
Output is correct |
5 |
Correct |
2 ms |
10844 KB |
Output is correct |
6 |
Correct |
2 ms |
10844 KB |
Output is correct |
7 |
Correct |
2 ms |
10672 KB |
Output is correct |
8 |
Correct |
2 ms |
10844 KB |
Output is correct |
9 |
Correct |
2 ms |
10844 KB |
Output is correct |
10 |
Correct |
2 ms |
10844 KB |
Output is correct |
11 |
Correct |
2 ms |
10720 KB |
Output is correct |
12 |
Correct |
2 ms |
10844 KB |
Output is correct |
13 |
Correct |
2 ms |
10844 KB |
Output is correct |
14 |
Correct |
12 ms |
29532 KB |
Output is correct |
15 |
Correct |
4 ms |
23500 KB |
Output is correct |
16 |
Correct |
4 ms |
19036 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
11 ms |
29788 KB |
Output is correct |
19 |
Correct |
7 ms |
29532 KB |
Output is correct |
20 |
Correct |
7 ms |
27996 KB |
Output is correct |
21 |
Correct |
10 ms |
29532 KB |
Output is correct |
22 |
Correct |
8 ms |
29532 KB |
Output is correct |
23 |
Correct |
7 ms |
27996 KB |
Output is correct |
24 |
Correct |
10 ms |
29532 KB |
Output is correct |
25 |
Correct |
7 ms |
29532 KB |
Output is correct |
26 |
Correct |
8 ms |
27996 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4560 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4440 KB |
Output is correct |
5 |
Correct |
2 ms |
10844 KB |
Output is correct |
6 |
Correct |
2 ms |
10844 KB |
Output is correct |
7 |
Correct |
2 ms |
10672 KB |
Output is correct |
8 |
Correct |
2 ms |
10844 KB |
Output is correct |
9 |
Correct |
2 ms |
10844 KB |
Output is correct |
10 |
Correct |
2 ms |
10844 KB |
Output is correct |
11 |
Correct |
2 ms |
10720 KB |
Output is correct |
12 |
Correct |
2 ms |
10844 KB |
Output is correct |
13 |
Correct |
2 ms |
10844 KB |
Output is correct |
14 |
Correct |
12 ms |
29532 KB |
Output is correct |
15 |
Correct |
4 ms |
23500 KB |
Output is correct |
16 |
Correct |
4 ms |
19036 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
11 ms |
29788 KB |
Output is correct |
19 |
Correct |
7 ms |
29532 KB |
Output is correct |
20 |
Correct |
7 ms |
27996 KB |
Output is correct |
21 |
Correct |
10 ms |
29532 KB |
Output is correct |
22 |
Correct |
8 ms |
29532 KB |
Output is correct |
23 |
Correct |
7 ms |
27996 KB |
Output is correct |
24 |
Correct |
10 ms |
29532 KB |
Output is correct |
25 |
Correct |
7 ms |
29532 KB |
Output is correct |
26 |
Correct |
8 ms |
27996 KB |
Output is correct |
27 |
Correct |
248 ms |
154876 KB |
Output is correct |
28 |
Correct |
11 ms |
85848 KB |
Output is correct |
29 |
Correct |
10 ms |
19548 KB |
Output is correct |
30 |
Correct |
2 ms |
4584 KB |
Output is correct |
31 |
Correct |
179 ms |
130448 KB |
Output is correct |
32 |
Correct |
172 ms |
154940 KB |
Output is correct |
33 |
Correct |
140 ms |
154632 KB |
Output is correct |
34 |
Correct |
208 ms |
147064 KB |
Output is correct |
35 |
Correct |
177 ms |
150756 KB |
Output is correct |
36 |
Correct |
171 ms |
150160 KB |
Output is correct |
37 |
Correct |
254 ms |
150288 KB |
Output is correct |
38 |
Correct |
115 ms |
126960 KB |
Output is correct |
39 |
Correct |
99 ms |
126032 KB |
Output is correct |