#include <bits/stdc++.h>
using namespace std;
const int N = 3001;
int m,n;
char s[N][N];
int ao[N][N],ai[N][N];
long long ans;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> m >> n;
for(int i = 1;i <= m;i++) for(int j = 1;j <= n;j++)
{
cin >> s[i][j];
if(s[i][j]=='O') ao[i][j]++;
else if(s[i][j]=='I') ai[i][j]++;
}
for(int i = m;i >= 1;i--) for(int j = n;j >= 1;j--) ao[i][j]+=ao[i][j+1],ai[i][j]+=ai[i+1][j];
for(int i = 1;i <= m;i++) for(int j = 1;j <= n;j++) if(s[i][j]=='J') ans+=(long long)ao[i][j]*(long long)ai[i][j];
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
504 KB |
Output is correct |
5 |
Correct |
5 ms |
1528 KB |
Output is correct |
6 |
Correct |
5 ms |
1528 KB |
Output is correct |
7 |
Correct |
6 ms |
1400 KB |
Output is correct |
8 |
Correct |
6 ms |
1528 KB |
Output is correct |
9 |
Correct |
6 ms |
1528 KB |
Output is correct |
10 |
Correct |
5 ms |
1400 KB |
Output is correct |
11 |
Correct |
6 ms |
1528 KB |
Output is correct |
12 |
Correct |
5 ms |
1532 KB |
Output is correct |
13 |
Correct |
5 ms |
1400 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
504 KB |
Output is correct |
5 |
Correct |
5 ms |
1528 KB |
Output is correct |
6 |
Correct |
5 ms |
1528 KB |
Output is correct |
7 |
Correct |
6 ms |
1400 KB |
Output is correct |
8 |
Correct |
6 ms |
1528 KB |
Output is correct |
9 |
Correct |
6 ms |
1528 KB |
Output is correct |
10 |
Correct |
5 ms |
1400 KB |
Output is correct |
11 |
Correct |
6 ms |
1528 KB |
Output is correct |
12 |
Correct |
5 ms |
1532 KB |
Output is correct |
13 |
Correct |
5 ms |
1400 KB |
Output is correct |
14 |
Correct |
15 ms |
7544 KB |
Output is correct |
15 |
Correct |
7 ms |
5116 KB |
Output is correct |
16 |
Correct |
9 ms |
4344 KB |
Output is correct |
17 |
Correct |
5 ms |
504 KB |
Output is correct |
18 |
Correct |
17 ms |
8056 KB |
Output is correct |
19 |
Correct |
14 ms |
7928 KB |
Output is correct |
20 |
Correct |
13 ms |
7800 KB |
Output is correct |
21 |
Correct |
16 ms |
8056 KB |
Output is correct |
22 |
Correct |
14 ms |
7928 KB |
Output is correct |
23 |
Correct |
13 ms |
7800 KB |
Output is correct |
24 |
Correct |
17 ms |
8056 KB |
Output is correct |
25 |
Correct |
14 ms |
7928 KB |
Output is correct |
26 |
Correct |
13 ms |
7932 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
504 KB |
Output is correct |
5 |
Correct |
5 ms |
1528 KB |
Output is correct |
6 |
Correct |
5 ms |
1528 KB |
Output is correct |
7 |
Correct |
6 ms |
1400 KB |
Output is correct |
8 |
Correct |
6 ms |
1528 KB |
Output is correct |
9 |
Correct |
6 ms |
1528 KB |
Output is correct |
10 |
Correct |
5 ms |
1400 KB |
Output is correct |
11 |
Correct |
6 ms |
1528 KB |
Output is correct |
12 |
Correct |
5 ms |
1532 KB |
Output is correct |
13 |
Correct |
5 ms |
1400 KB |
Output is correct |
14 |
Correct |
15 ms |
7544 KB |
Output is correct |
15 |
Correct |
7 ms |
5116 KB |
Output is correct |
16 |
Correct |
9 ms |
4344 KB |
Output is correct |
17 |
Correct |
5 ms |
504 KB |
Output is correct |
18 |
Correct |
17 ms |
8056 KB |
Output is correct |
19 |
Correct |
14 ms |
7928 KB |
Output is correct |
20 |
Correct |
13 ms |
7800 KB |
Output is correct |
21 |
Correct |
16 ms |
8056 KB |
Output is correct |
22 |
Correct |
14 ms |
7928 KB |
Output is correct |
23 |
Correct |
13 ms |
7800 KB |
Output is correct |
24 |
Correct |
17 ms |
8056 KB |
Output is correct |
25 |
Correct |
14 ms |
7928 KB |
Output is correct |
26 |
Correct |
13 ms |
7932 KB |
Output is correct |
27 |
Correct |
322 ms |
83576 KB |
Output is correct |
28 |
Correct |
18 ms |
26104 KB |
Output is correct |
29 |
Correct |
20 ms |
7800 KB |
Output is correct |
30 |
Correct |
5 ms |
632 KB |
Output is correct |
31 |
Correct |
240 ms |
70396 KB |
Output is correct |
32 |
Correct |
250 ms |
83560 KB |
Output is correct |
33 |
Correct |
200 ms |
83272 KB |
Output is correct |
34 |
Correct |
291 ms |
81128 KB |
Output is correct |
35 |
Correct |
257 ms |
83832 KB |
Output is correct |
36 |
Correct |
199 ms |
83320 KB |
Output is correct |
37 |
Correct |
332 ms |
83704 KB |
Output is correct |
38 |
Correct |
178 ms |
70376 KB |
Output is correct |
39 |
Correct |
154 ms |
70072 KB |
Output is correct |