#include <bits/stdc++.h>
using namespace std;
long long n, m, s, nri, nro, v[3001][3001], w[3001][3001];
char a[3001][3001];
int main()
{
cin>>n>>m;
for(int i=1; i<=n; i++)
for(int j=1; j<=m; j++)
cin>>a[i][j];
for(int j=m; j>=1; j--)
{
for(int i=n; i>=1; i--)
if(a[i][j]=='I')
{
nri++;
v[i][j]=nri;
}
else
v[i][j]=nri;
nri=0;
}
for(int i=n; i>=1; i--)
{
for(int j=m; j>=1; j--)
if(a[i][j]=='O')
{
nro++;
w[i][j]=nro;
}
else
w[i][j]=nro;
nro=0;
}
for(int i=1; i<=n; i++)
for(int j=1; j<=m; j++)
if(a[i][j]=='J')
s+=v[i][j]*w[i][j];
cout<<s;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
304 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
1464 KB |
Output is correct |
6 |
Correct |
1 ms |
1460 KB |
Output is correct |
7 |
Correct |
2 ms |
1356 KB |
Output is correct |
8 |
Correct |
2 ms |
1484 KB |
Output is correct |
9 |
Correct |
1 ms |
1484 KB |
Output is correct |
10 |
Correct |
2 ms |
1356 KB |
Output is correct |
11 |
Correct |
2 ms |
1484 KB |
Output is correct |
12 |
Correct |
1 ms |
1484 KB |
Output is correct |
13 |
Correct |
2 ms |
1356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
304 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
1464 KB |
Output is correct |
6 |
Correct |
1 ms |
1460 KB |
Output is correct |
7 |
Correct |
2 ms |
1356 KB |
Output is correct |
8 |
Correct |
2 ms |
1484 KB |
Output is correct |
9 |
Correct |
1 ms |
1484 KB |
Output is correct |
10 |
Correct |
2 ms |
1356 KB |
Output is correct |
11 |
Correct |
2 ms |
1484 KB |
Output is correct |
12 |
Correct |
1 ms |
1484 KB |
Output is correct |
13 |
Correct |
2 ms |
1356 KB |
Output is correct |
14 |
Correct |
16 ms |
8892 KB |
Output is correct |
15 |
Correct |
2 ms |
4940 KB |
Output is correct |
16 |
Correct |
9 ms |
5252 KB |
Output is correct |
17 |
Correct |
1 ms |
460 KB |
Output is correct |
18 |
Correct |
20 ms |
9924 KB |
Output is correct |
19 |
Correct |
18 ms |
9668 KB |
Output is correct |
20 |
Correct |
18 ms |
9744 KB |
Output is correct |
21 |
Correct |
21 ms |
9876 KB |
Output is correct |
22 |
Correct |
18 ms |
9744 KB |
Output is correct |
23 |
Correct |
18 ms |
9656 KB |
Output is correct |
24 |
Correct |
20 ms |
9924 KB |
Output is correct |
25 |
Correct |
19 ms |
9768 KB |
Output is correct |
26 |
Correct |
18 ms |
9672 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
304 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
1464 KB |
Output is correct |
6 |
Correct |
1 ms |
1460 KB |
Output is correct |
7 |
Correct |
2 ms |
1356 KB |
Output is correct |
8 |
Correct |
2 ms |
1484 KB |
Output is correct |
9 |
Correct |
1 ms |
1484 KB |
Output is correct |
10 |
Correct |
2 ms |
1356 KB |
Output is correct |
11 |
Correct |
2 ms |
1484 KB |
Output is correct |
12 |
Correct |
1 ms |
1484 KB |
Output is correct |
13 |
Correct |
2 ms |
1356 KB |
Output is correct |
14 |
Correct |
16 ms |
8892 KB |
Output is correct |
15 |
Correct |
2 ms |
4940 KB |
Output is correct |
16 |
Correct |
9 ms |
5252 KB |
Output is correct |
17 |
Correct |
1 ms |
460 KB |
Output is correct |
18 |
Correct |
20 ms |
9924 KB |
Output is correct |
19 |
Correct |
18 ms |
9668 KB |
Output is correct |
20 |
Correct |
18 ms |
9744 KB |
Output is correct |
21 |
Correct |
21 ms |
9876 KB |
Output is correct |
22 |
Correct |
18 ms |
9744 KB |
Output is correct |
23 |
Correct |
18 ms |
9656 KB |
Output is correct |
24 |
Correct |
20 ms |
9924 KB |
Output is correct |
25 |
Correct |
19 ms |
9768 KB |
Output is correct |
26 |
Correct |
18 ms |
9672 KB |
Output is correct |
27 |
Correct |
702 ms |
158268 KB |
Output is correct |
28 |
Correct |
12 ms |
26188 KB |
Output is correct |
29 |
Correct |
42 ms |
13748 KB |
Output is correct |
30 |
Correct |
2 ms |
700 KB |
Output is correct |
31 |
Correct |
515 ms |
131276 KB |
Output is correct |
32 |
Correct |
681 ms |
158844 KB |
Output is correct |
33 |
Correct |
666 ms |
158276 KB |
Output is correct |
34 |
Correct |
600 ms |
152132 KB |
Output is correct |
35 |
Correct |
673 ms |
158784 KB |
Output is correct |
36 |
Correct |
673 ms |
158300 KB |
Output is correct |
37 |
Correct |
742 ms |
158728 KB |
Output is correct |
38 |
Correct |
472 ms |
130776 KB |
Output is correct |
39 |
Correct |
473 ms |
130728 KB |
Output is correct |