#include <bits/stdc++.h>
using namespace std;
const int N=3*1e3+2;
char T[N][N];
int H[N][N],W[N][N];
int main()
{
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
cin>>T[i][j];
}
}
for(int i=1;i<=n;i++)
{
int wyn=0;
for(int j=m;j>=1;j--)
{
W[i][j]=wyn;
if(T[i][j]=='O')wyn++;
}
}
for(int j=1;j<=m;j++)
{
int wyn=0;
for(int i=n;i>=1;i--)
{
H[i][j]=wyn;
if(T[i][j]=='I')wyn++;
}
}
long long wyn=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if(T[i][j]=='J')
{
wyn+=H[i][j]*W[i][j];
}
}
}
cout<<wyn;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1364 KB |
Output is correct |
7 |
Correct |
1 ms |
1364 KB |
Output is correct |
8 |
Correct |
1 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1364 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1364 KB |
Output is correct |
13 |
Correct |
1 ms |
1356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1364 KB |
Output is correct |
7 |
Correct |
1 ms |
1364 KB |
Output is correct |
8 |
Correct |
1 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1364 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1364 KB |
Output is correct |
13 |
Correct |
1 ms |
1356 KB |
Output is correct |
14 |
Correct |
10 ms |
7380 KB |
Output is correct |
15 |
Correct |
2 ms |
4948 KB |
Output is correct |
16 |
Correct |
6 ms |
4208 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
12 ms |
7816 KB |
Output is correct |
19 |
Correct |
11 ms |
7764 KB |
Output is correct |
20 |
Correct |
11 ms |
7636 KB |
Output is correct |
21 |
Correct |
16 ms |
7784 KB |
Output is correct |
22 |
Correct |
12 ms |
7768 KB |
Output is correct |
23 |
Correct |
14 ms |
7728 KB |
Output is correct |
24 |
Correct |
13 ms |
7764 KB |
Output is correct |
25 |
Correct |
11 ms |
7764 KB |
Output is correct |
26 |
Correct |
11 ms |
7696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1364 KB |
Output is correct |
7 |
Correct |
1 ms |
1364 KB |
Output is correct |
8 |
Correct |
1 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1364 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1364 KB |
Output is correct |
13 |
Correct |
1 ms |
1356 KB |
Output is correct |
14 |
Correct |
10 ms |
7380 KB |
Output is correct |
15 |
Correct |
2 ms |
4948 KB |
Output is correct |
16 |
Correct |
6 ms |
4208 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
12 ms |
7816 KB |
Output is correct |
19 |
Correct |
11 ms |
7764 KB |
Output is correct |
20 |
Correct |
11 ms |
7636 KB |
Output is correct |
21 |
Correct |
16 ms |
7784 KB |
Output is correct |
22 |
Correct |
12 ms |
7768 KB |
Output is correct |
23 |
Correct |
14 ms |
7728 KB |
Output is correct |
24 |
Correct |
13 ms |
7764 KB |
Output is correct |
25 |
Correct |
11 ms |
7764 KB |
Output is correct |
26 |
Correct |
11 ms |
7696 KB |
Output is correct |
27 |
Correct |
447 ms |
79840 KB |
Output is correct |
28 |
Correct |
10 ms |
25940 KB |
Output is correct |
29 |
Correct |
25 ms |
7156 KB |
Output is correct |
30 |
Correct |
1 ms |
596 KB |
Output is correct |
31 |
Correct |
331 ms |
66424 KB |
Output is correct |
32 |
Correct |
451 ms |
79792 KB |
Output is correct |
33 |
Correct |
434 ms |
79592 KB |
Output is correct |
34 |
Correct |
409 ms |
77128 KB |
Output is correct |
35 |
Correct |
441 ms |
79852 KB |
Output is correct |
36 |
Correct |
450 ms |
79524 KB |
Output is correct |
37 |
Correct |
461 ms |
79772 KB |
Output is correct |
38 |
Correct |
309 ms |
66512 KB |
Output is correct |
39 |
Correct |
316 ms |
66324 KB |
Output is correct |