#include<bits/stdc++.h>
using namespace std;
#define int long long int
int n,m;
string s[3005];
int suff_o[3005][3005];
int suff_i[3005][3005];
int sum;
int32_t main()
{
cin >> n >> m;
for(int i=0;i<n;i++)
cin >> s[i];
for(int i=0;i<n;i++)
{
for(int j=m-1;j>0;j--)
{
suff_o[i][j-1]=suff_o[i][j];
if(s[i][j]=='O') suff_o[i][j-1]++;
}
}
for(int i=0;i<m;i++)
{
for(int j=n-1;j>0;j--)
{
suff_i[j-1][i]=suff_i[j][i];
if(s[j][i]=='I') suff_i[j-1][i]++;
}
}
sum=0;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
if(s[i][j]=='J')
{
sum+=suff_i[i][j]*suff_o[i][j];
}
}
}
cout << sum;
/*for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
cout << suff_o[i][j] << ' ';
}
cout << '\n';
}
cout << '\n';
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
cout << suff_i[i][j] << ' ';
}
cout << '\n';
}*/
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
600 KB |
Output isn't correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
7 |
Incorrect |
13 ms |
23292 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
9 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
10 |
Incorrect |
0 ms |
600 KB |
Output isn't correct |
11 |
Incorrect |
0 ms |
600 KB |
Output isn't correct |
12 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
13 |
Correct |
1 ms |
860 KB |
Output is correct |
14 |
Incorrect |
1 ms |
860 KB |
Output isn't correct |
15 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
16 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
17 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
18 |
Incorrect |
0 ms |
600 KB |
Output isn't correct |
19 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
20 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
21 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
22 |
Incorrect |
1 ms |
1112 KB |
Output isn't correct |
23 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
24 |
Incorrect |
1 ms |
856 KB |
Output isn't correct |
25 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
26 |
Incorrect |
1 ms |
860 KB |
Output isn't correct |
27 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
28 |
Incorrect |
1 ms |
860 KB |
Output isn't correct |
29 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
30 |
Incorrect |
1 ms |
1112 KB |
Output isn't correct |
31 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |
32 |
Incorrect |
1 ms |
1116 KB |
Output isn't correct |
33 |
Incorrect |
3 ms |
7004 KB |
Output isn't correct |
34 |
Incorrect |
4 ms |
9052 KB |
Output isn't correct |
35 |
Incorrect |
5 ms |
9820 KB |
Output isn't correct |
36 |
Incorrect |
4 ms |
9052 KB |
Output isn't correct |
37 |
Incorrect |
5 ms |
11352 KB |
Output isn't correct |
38 |
Incorrect |
6 ms |
12124 KB |
Output isn't correct |
39 |
Incorrect |
4 ms |
10844 KB |
Output isn't correct |
40 |
Incorrect |
6 ms |
13660 KB |
Output isn't correct |
41 |
Incorrect |
7 ms |
14428 KB |
Output isn't correct |
42 |
Incorrect |
6 ms |
11356 KB |
Output isn't correct |
43 |
Incorrect |
7 ms |
14420 KB |
Output isn't correct |
44 |
Incorrect |
8 ms |
15708 KB |
Output isn't correct |
45 |
Incorrect |
6 ms |
13480 KB |
Output isn't correct |
46 |
Incorrect |
8 ms |
16732 KB |
Output isn't correct |
47 |
Incorrect |
10 ms |
18012 KB |
Output isn't correct |
48 |
Incorrect |
7 ms |
13660 KB |
Output isn't correct |
49 |
Incorrect |
9 ms |
17668 KB |
Output isn't correct |
50 |
Incorrect |
11 ms |
19292 KB |
Output isn't correct |
51 |
Incorrect |
8 ms |
15452 KB |
Output isn't correct |
52 |
Incorrect |
11 ms |
19804 KB |
Output isn't correct |
53 |
Incorrect |
12 ms |
21596 KB |
Output isn't correct |
54 |
Incorrect |
9 ms |
15764 KB |
Output isn't correct |
55 |
Incorrect |
12 ms |
20828 KB |
Output isn't correct |
56 |
Incorrect |
15 ms |
22988 KB |
Output isn't correct |
57 |
Incorrect |
10 ms |
17756 KB |
Output isn't correct |
58 |
Incorrect |
14 ms |
23132 KB |
Output isn't correct |
59 |
Incorrect |
19 ms |
25436 KB |
Output isn't correct |
60 |
Incorrect |
11 ms |
19804 KB |
Output isn't correct |
61 |
Incorrect |
15 ms |
25436 KB |
Output isn't correct |
62 |
Incorrect |
19 ms |
27992 KB |
Output isn't correct |
63 |
Correct |
13 ms |
22876 KB |
Output is correct |
64 |
Incorrect |
19 ms |
28332 KB |
Output isn't correct |
65 |
Incorrect |
12 ms |
22896 KB |
Output isn't correct |
66 |
Incorrect |
12 ms |
22876 KB |
Output isn't correct |
67 |
Incorrect |
13 ms |
23008 KB |
Output isn't correct |
68 |
Correct |
13 ms |
23328 KB |
Output is correct |
69 |
Incorrect |
14 ms |
24600 KB |
Output isn't correct |
70 |
Incorrect |
13 ms |
23008 KB |
Output isn't correct |
71 |
Incorrect |
18 ms |
23132 KB |
Output isn't correct |
72 |
Incorrect |
14 ms |
24668 KB |
Output isn't correct |
73 |
Incorrect |
12 ms |
22876 KB |
Output isn't correct |
74 |
Incorrect |
16 ms |
26156 KB |
Output isn't correct |
75 |
Incorrect |
12 ms |
22876 KB |
Output isn't correct |
76 |
Incorrect |
12 ms |
22992 KB |
Output isn't correct |
77 |
Incorrect |
14 ms |
23132 KB |
Output isn't correct |
78 |
Incorrect |
12 ms |
23132 KB |
Output isn't correct |
79 |
Incorrect |
19 ms |
26204 KB |
Output isn't correct |
80 |
Incorrect |
12 ms |
23132 KB |
Output isn't correct |
81 |
Incorrect |
13 ms |
22876 KB |
Output isn't correct |
82 |
Incorrect |
12 ms |
23192 KB |
Output isn't correct |
83 |
Correct |
12 ms |
23384 KB |
Output is correct |
84 |
Incorrect |
16 ms |
26460 KB |
Output isn't correct |
85 |
Incorrect |
13 ms |
23132 KB |
Output isn't correct |
86 |
Incorrect |
12 ms |
23092 KB |
Output isn't correct |
87 |
Incorrect |
13 ms |
23128 KB |
Output isn't correct |
88 |
Correct |
13 ms |
23048 KB |
Output is correct |
89 |
Incorrect |
18 ms |
26716 KB |
Output isn't correct |
90 |
Incorrect |
13 ms |
23132 KB |
Output isn't correct |
91 |
Incorrect |
13 ms |
23384 KB |
Output isn't correct |
92 |
Incorrect |
13 ms |
23132 KB |
Output isn't correct |