#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
int n,m,orb[3050][3050],ing[3050][3050];
long long ans;
char c[3050][3050];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n>>m;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
cin>>c[i][j];
if(c[i][j]=='I')ing[i][j]++;
else if(c[i][j]=='O') orb[i][j]++;
}
}
for(int i=0;i<n;i++)
{
for(int j=m-1;j>=0;j--)orb[i][j]+=orb[i][j+1];
}
for(int i=0;i<m;i++)
{
for(int j=n-1;j>=0;j--)ing[j][i]+=ing[j+1][i];
}
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
if(c[i][j]=='J')ans+=ing[i][j]*orb[i][j];
}
}
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
3 ms |
1528 KB |
Output is correct |
6 |
Correct |
3 ms |
1528 KB |
Output is correct |
7 |
Correct |
3 ms |
1400 KB |
Output is correct |
8 |
Correct |
3 ms |
1528 KB |
Output is correct |
9 |
Correct |
3 ms |
1528 KB |
Output is correct |
10 |
Correct |
3 ms |
1400 KB |
Output is correct |
11 |
Correct |
3 ms |
1528 KB |
Output is correct |
12 |
Correct |
3 ms |
1528 KB |
Output is correct |
13 |
Correct |
3 ms |
1400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
3 ms |
1528 KB |
Output is correct |
6 |
Correct |
3 ms |
1528 KB |
Output is correct |
7 |
Correct |
3 ms |
1400 KB |
Output is correct |
8 |
Correct |
3 ms |
1528 KB |
Output is correct |
9 |
Correct |
3 ms |
1528 KB |
Output is correct |
10 |
Correct |
3 ms |
1400 KB |
Output is correct |
11 |
Correct |
3 ms |
1528 KB |
Output is correct |
12 |
Correct |
3 ms |
1528 KB |
Output is correct |
13 |
Correct |
3 ms |
1400 KB |
Output is correct |
14 |
Correct |
14 ms |
7416 KB |
Output is correct |
15 |
Correct |
6 ms |
4984 KB |
Output is correct |
16 |
Correct |
8 ms |
4216 KB |
Output is correct |
17 |
Correct |
2 ms |
504 KB |
Output is correct |
18 |
Correct |
17 ms |
7800 KB |
Output is correct |
19 |
Correct |
13 ms |
7772 KB |
Output is correct |
20 |
Correct |
13 ms |
7672 KB |
Output is correct |
21 |
Correct |
17 ms |
8056 KB |
Output is correct |
22 |
Correct |
13 ms |
7928 KB |
Output is correct |
23 |
Correct |
13 ms |
7932 KB |
Output is correct |
24 |
Correct |
17 ms |
8056 KB |
Output is correct |
25 |
Correct |
13 ms |
8056 KB |
Output is correct |
26 |
Correct |
13 ms |
7928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
3 ms |
1528 KB |
Output is correct |
6 |
Correct |
3 ms |
1528 KB |
Output is correct |
7 |
Correct |
3 ms |
1400 KB |
Output is correct |
8 |
Correct |
3 ms |
1528 KB |
Output is correct |
9 |
Correct |
3 ms |
1528 KB |
Output is correct |
10 |
Correct |
3 ms |
1400 KB |
Output is correct |
11 |
Correct |
3 ms |
1528 KB |
Output is correct |
12 |
Correct |
3 ms |
1528 KB |
Output is correct |
13 |
Correct |
3 ms |
1400 KB |
Output is correct |
14 |
Correct |
14 ms |
7416 KB |
Output is correct |
15 |
Correct |
6 ms |
4984 KB |
Output is correct |
16 |
Correct |
8 ms |
4216 KB |
Output is correct |
17 |
Correct |
2 ms |
504 KB |
Output is correct |
18 |
Correct |
17 ms |
7800 KB |
Output is correct |
19 |
Correct |
13 ms |
7772 KB |
Output is correct |
20 |
Correct |
13 ms |
7672 KB |
Output is correct |
21 |
Correct |
17 ms |
8056 KB |
Output is correct |
22 |
Correct |
13 ms |
7928 KB |
Output is correct |
23 |
Correct |
13 ms |
7932 KB |
Output is correct |
24 |
Correct |
17 ms |
8056 KB |
Output is correct |
25 |
Correct |
13 ms |
8056 KB |
Output is correct |
26 |
Correct |
13 ms |
7928 KB |
Output is correct |
27 |
Correct |
433 ms |
89464 KB |
Output is correct |
28 |
Correct |
22 ms |
26232 KB |
Output is correct |
29 |
Correct |
21 ms |
7928 KB |
Output is correct |
30 |
Correct |
3 ms |
632 KB |
Output is correct |
31 |
Correct |
316 ms |
73680 KB |
Output is correct |
32 |
Correct |
349 ms |
89708 KB |
Output is correct |
33 |
Correct |
325 ms |
89468 KB |
Output is correct |
34 |
Correct |
375 ms |
85368 KB |
Output is correct |
35 |
Correct |
355 ms |
89720 KB |
Output is correct |
36 |
Correct |
340 ms |
89480 KB |
Output is correct |
37 |
Correct |
464 ms |
89876 KB |
Output is correct |
38 |
Correct |
237 ms |
73592 KB |
Output is correct |
39 |
Correct |
224 ms |
73312 KB |
Output is correct |