#include<bits/stdc++.h>
#define pii pair<int,int>
#define ll long long
using namespace std;
int main()
{
int h,w;
cin>>h>>w;
ll os[h][w]={},is[h][w]={};
int js[h][w]={};
for(int i=0;i<h;i++)
{
for(int j=0;j<w;j++)
{
char c;cin>>c;
if(c=='J')js[i][j]=1;
else if(c=='O')os[i][j]=1;
else is[i][j]=1;
}
}
for(int i=1;i<h;i++)
for(int j=0;j<w;j++)is[i][j]+=is[i-1][j];
for(int i=0;i<h;i++)
for(int j=1;j<w;j++)os[i][j]+=os[i][j-1];
ll ans=0;
for(int i=0;i<h;i++)
{
for(int j=0;j<w;j++)
{
if(js[i][j])
{
ans+=(is[h-1][j]-is[i][j])*(os[i][w-1]-os[i][j]);
}
}
}
cout<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
6 ms |
512 KB |
Output is correct |
6 |
Correct |
5 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
512 KB |
Output is correct |
8 |
Correct |
6 ms |
512 KB |
Output is correct |
9 |
Correct |
5 ms |
512 KB |
Output is correct |
10 |
Correct |
5 ms |
512 KB |
Output is correct |
11 |
Correct |
6 ms |
512 KB |
Output is correct |
12 |
Correct |
5 ms |
512 KB |
Output is correct |
13 |
Correct |
5 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
6 ms |
512 KB |
Output is correct |
6 |
Correct |
5 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
512 KB |
Output is correct |
8 |
Correct |
6 ms |
512 KB |
Output is correct |
9 |
Correct |
5 ms |
512 KB |
Output is correct |
10 |
Correct |
5 ms |
512 KB |
Output is correct |
11 |
Correct |
6 ms |
512 KB |
Output is correct |
12 |
Correct |
5 ms |
512 KB |
Output is correct |
13 |
Correct |
5 ms |
512 KB |
Output is correct |
14 |
Correct |
26 ms |
4224 KB |
Output is correct |
15 |
Correct |
5 ms |
380 KB |
Output is correct |
16 |
Correct |
18 ms |
2944 KB |
Output is correct |
17 |
Correct |
6 ms |
384 KB |
Output is correct |
18 |
Correct |
32 ms |
5496 KB |
Output is correct |
19 |
Correct |
28 ms |
5248 KB |
Output is correct |
20 |
Correct |
28 ms |
5376 KB |
Output is correct |
21 |
Correct |
32 ms |
5492 KB |
Output is correct |
22 |
Correct |
29 ms |
5248 KB |
Output is correct |
23 |
Correct |
28 ms |
5376 KB |
Output is correct |
24 |
Correct |
31 ms |
5504 KB |
Output is correct |
25 |
Correct |
28 ms |
5248 KB |
Output is correct |
26 |
Correct |
28 ms |
5376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
6 ms |
512 KB |
Output is correct |
6 |
Correct |
5 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
512 KB |
Output is correct |
8 |
Correct |
6 ms |
512 KB |
Output is correct |
9 |
Correct |
5 ms |
512 KB |
Output is correct |
10 |
Correct |
5 ms |
512 KB |
Output is correct |
11 |
Correct |
6 ms |
512 KB |
Output is correct |
12 |
Correct |
5 ms |
512 KB |
Output is correct |
13 |
Correct |
5 ms |
512 KB |
Output is correct |
14 |
Correct |
26 ms |
4224 KB |
Output is correct |
15 |
Correct |
5 ms |
380 KB |
Output is correct |
16 |
Correct |
18 ms |
2944 KB |
Output is correct |
17 |
Correct |
6 ms |
384 KB |
Output is correct |
18 |
Correct |
32 ms |
5496 KB |
Output is correct |
19 |
Correct |
28 ms |
5248 KB |
Output is correct |
20 |
Correct |
28 ms |
5376 KB |
Output is correct |
21 |
Correct |
32 ms |
5492 KB |
Output is correct |
22 |
Correct |
29 ms |
5248 KB |
Output is correct |
23 |
Correct |
28 ms |
5376 KB |
Output is correct |
24 |
Correct |
31 ms |
5504 KB |
Output is correct |
25 |
Correct |
28 ms |
5248 KB |
Output is correct |
26 |
Correct |
28 ms |
5376 KB |
Output is correct |
27 |
Correct |
927 ms |
175112 KB |
Output is correct |
28 |
Correct |
7 ms |
896 KB |
Output is correct |
29 |
Correct |
66 ms |
13688 KB |
Output is correct |
30 |
Correct |
7 ms |
768 KB |
Output is correct |
31 |
Correct |
685 ms |
128760 KB |
Output is correct |
32 |
Correct |
886 ms |
183996 KB |
Output is correct |
33 |
Correct |
852 ms |
184584 KB |
Output is correct |
34 |
Correct |
802 ms |
149264 KB |
Output is correct |
35 |
Correct |
904 ms |
183932 KB |
Output is correct |
36 |
Correct |
857 ms |
184568 KB |
Output is correct |
37 |
Correct |
976 ms |
185184 KB |
Output is correct |
38 |
Correct |
604 ms |
127736 KB |
Output is correct |
39 |
Correct |
599 ms |
128176 KB |
Output is correct |