#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int N = 3001,INF=1e12;
char arr[N][N];
int jew[N][N],ob[N][N],col[N][N];
int32_t main()
{
//freopen("abc.in", "r", stdin);
int h , w;
cin >> h >> w;
for(int i = 0 ; i < h ; i ++){
for(int j = 0 ; j < w; j ++){
cin>>arr[i][j];
if(arr[i][j]=='J')
jew[i][j]++;
else if(arr[i][j]=='O')
ob[i][j]++;
else if(arr[i][j]=='I')
col[i][j]++;
if(j) ob[i][j]+=ob[i][j-1];
if(i) col[i][j]+=col[i-1][j];
}
}
int ans=0;
for(int i = 0; i < h ; i ++)
{
for(int j = 0 ; j < w ; j ++)
{
if(jew[i][j]){
ans+=(ob[i][w-1]-ob[i][j])*(col[h-1][j]-col[i][j]);
}
}
}
cout<<ans<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
388 KB |
Output is correct |
2 |
Correct |
1 ms |
296 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
3 ms |
2004 KB |
Output is correct |
6 |
Correct |
2 ms |
1876 KB |
Output is correct |
7 |
Correct |
2 ms |
1748 KB |
Output is correct |
8 |
Correct |
3 ms |
2004 KB |
Output is correct |
9 |
Correct |
2 ms |
2004 KB |
Output is correct |
10 |
Correct |
2 ms |
1876 KB |
Output is correct |
11 |
Correct |
2 ms |
2004 KB |
Output is correct |
12 |
Correct |
2 ms |
1876 KB |
Output is correct |
13 |
Correct |
2 ms |
1748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
388 KB |
Output is correct |
2 |
Correct |
1 ms |
296 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
3 ms |
2004 KB |
Output is correct |
6 |
Correct |
2 ms |
1876 KB |
Output is correct |
7 |
Correct |
2 ms |
1748 KB |
Output is correct |
8 |
Correct |
3 ms |
2004 KB |
Output is correct |
9 |
Correct |
2 ms |
2004 KB |
Output is correct |
10 |
Correct |
2 ms |
1876 KB |
Output is correct |
11 |
Correct |
2 ms |
2004 KB |
Output is correct |
12 |
Correct |
2 ms |
1876 KB |
Output is correct |
13 |
Correct |
2 ms |
1748 KB |
Output is correct |
14 |
Correct |
19 ms |
12372 KB |
Output is correct |
15 |
Correct |
4 ms |
6612 KB |
Output is correct |
16 |
Correct |
11 ms |
6796 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
24 ms |
13884 KB |
Output is correct |
19 |
Correct |
23 ms |
12752 KB |
Output is correct |
20 |
Correct |
23 ms |
12304 KB |
Output is correct |
21 |
Correct |
28 ms |
13868 KB |
Output is correct |
22 |
Correct |
22 ms |
13072 KB |
Output is correct |
23 |
Correct |
20 ms |
12344 KB |
Output is correct |
24 |
Correct |
24 ms |
13912 KB |
Output is correct |
25 |
Correct |
22 ms |
12736 KB |
Output is correct |
26 |
Correct |
21 ms |
12352 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
388 KB |
Output is correct |
2 |
Correct |
1 ms |
296 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
3 ms |
2004 KB |
Output is correct |
6 |
Correct |
2 ms |
1876 KB |
Output is correct |
7 |
Correct |
2 ms |
1748 KB |
Output is correct |
8 |
Correct |
3 ms |
2004 KB |
Output is correct |
9 |
Correct |
2 ms |
2004 KB |
Output is correct |
10 |
Correct |
2 ms |
1876 KB |
Output is correct |
11 |
Correct |
2 ms |
2004 KB |
Output is correct |
12 |
Correct |
2 ms |
1876 KB |
Output is correct |
13 |
Correct |
2 ms |
1748 KB |
Output is correct |
14 |
Correct |
19 ms |
12372 KB |
Output is correct |
15 |
Correct |
4 ms |
6612 KB |
Output is correct |
16 |
Correct |
11 ms |
6796 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
24 ms |
13884 KB |
Output is correct |
19 |
Correct |
23 ms |
12752 KB |
Output is correct |
20 |
Correct |
23 ms |
12304 KB |
Output is correct |
21 |
Correct |
28 ms |
13868 KB |
Output is correct |
22 |
Correct |
22 ms |
13072 KB |
Output is correct |
23 |
Correct |
20 ms |
12344 KB |
Output is correct |
24 |
Correct |
24 ms |
13912 KB |
Output is correct |
25 |
Correct |
22 ms |
12736 KB |
Output is correct |
26 |
Correct |
21 ms |
12352 KB |
Output is correct |
27 |
Correct |
687 ms |
228780 KB |
Output is correct |
28 |
Correct |
19 ms |
35156 KB |
Output is correct |
29 |
Correct |
55 ms |
16808 KB |
Output is correct |
30 |
Correct |
3 ms |
960 KB |
Output is correct |
31 |
Correct |
498 ms |
190000 KB |
Output is correct |
32 |
Correct |
654 ms |
207004 KB |
Output is correct |
33 |
Correct |
618 ms |
193612 KB |
Output is correct |
34 |
Correct |
586 ms |
220268 KB |
Output is correct |
35 |
Correct |
635 ms |
212668 KB |
Output is correct |
36 |
Correct |
602 ms |
193800 KB |
Output is correct |
37 |
Correct |
735 ms |
229300 KB |
Output is correct |
38 |
Correct |
429 ms |
167124 KB |
Output is correct |
39 |
Correct |
432 ms |
156904 KB |
Output is correct |