#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mn=3069;
int a[mn][mn];
ll red[mn][mn];
ll kolona[mn][mn];
int main()
{
int n,m;
cin>>n>>m;
for(int i=0;i<n;i++)
{
string s;
cin>>s;
for(int j=0;j<m;j++)
{
if(s[j]=='J') a[i][j]=0;
else if(s[j]=='O') a[i][j]=1;
else a[i][j]=2;
}
}
ll kolko=0;
for(int i=0;i<m;i++)
{
if(a[0][i]==2) red[0][i]=1;
}
for(int i=0;i<n;i++)
{
if(a[i][0]==1) kolona[i][0]=1;
}
for(int i=0;i<n;i++)
{
for(int j=1;j<m;j++)
{
kolona[i][j]=kolona[i][j-1];
if(a[i][j]==1) kolona[i][j]++;
//cout<<kolona[i][j]<<" ";
}
//cout<<endl;
}
for(int i=1;i<n;i++)
{
for(int j=0;j<m;j++)
{
red[i][j]=red[i-1][j];
if(a[i][j]==2) red[i][j]++;
}
}
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
if(a[i][j]==0)
{
/*cout<<i<<" "<<j<<endl;
cout<<kolona[i][m-1]<<" "<<kolona[i][j]<<endl;
cout<<red[n-1][j]<<" "<<red[i][j]<<endl;*/
kolko+=((kolona[i][m-1]-kolona[i][j])*(red[n-1][j]-red[i][j]));
}
}
}
cout<<kolko<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
1536 KB |
Output is correct |
6 |
Correct |
2 ms |
1536 KB |
Output is correct |
7 |
Correct |
2 ms |
1408 KB |
Output is correct |
8 |
Correct |
2 ms |
1536 KB |
Output is correct |
9 |
Correct |
2 ms |
1536 KB |
Output is correct |
10 |
Correct |
2 ms |
1408 KB |
Output is correct |
11 |
Correct |
2 ms |
1536 KB |
Output is correct |
12 |
Correct |
2 ms |
1536 KB |
Output is correct |
13 |
Correct |
2 ms |
1408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
1536 KB |
Output is correct |
6 |
Correct |
2 ms |
1536 KB |
Output is correct |
7 |
Correct |
2 ms |
1408 KB |
Output is correct |
8 |
Correct |
2 ms |
1536 KB |
Output is correct |
9 |
Correct |
2 ms |
1536 KB |
Output is correct |
10 |
Correct |
2 ms |
1408 KB |
Output is correct |
11 |
Correct |
2 ms |
1536 KB |
Output is correct |
12 |
Correct |
2 ms |
1536 KB |
Output is correct |
13 |
Correct |
2 ms |
1408 KB |
Output is correct |
14 |
Correct |
20 ms |
10324 KB |
Output is correct |
15 |
Correct |
4 ms |
5504 KB |
Output is correct |
16 |
Correct |
11 ms |
6144 KB |
Output is correct |
17 |
Correct |
1 ms |
512 KB |
Output is correct |
18 |
Correct |
24 ms |
11640 KB |
Output is correct |
19 |
Correct |
19 ms |
11392 KB |
Output is correct |
20 |
Correct |
20 ms |
11392 KB |
Output is correct |
21 |
Correct |
25 ms |
11648 KB |
Output is correct |
22 |
Correct |
20 ms |
11392 KB |
Output is correct |
23 |
Correct |
20 ms |
11392 KB |
Output is correct |
24 |
Correct |
24 ms |
11648 KB |
Output is correct |
25 |
Correct |
21 ms |
11392 KB |
Output is correct |
26 |
Correct |
20 ms |
11392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
1536 KB |
Output is correct |
6 |
Correct |
2 ms |
1536 KB |
Output is correct |
7 |
Correct |
2 ms |
1408 KB |
Output is correct |
8 |
Correct |
2 ms |
1536 KB |
Output is correct |
9 |
Correct |
2 ms |
1536 KB |
Output is correct |
10 |
Correct |
2 ms |
1408 KB |
Output is correct |
11 |
Correct |
2 ms |
1536 KB |
Output is correct |
12 |
Correct |
2 ms |
1536 KB |
Output is correct |
13 |
Correct |
2 ms |
1408 KB |
Output is correct |
14 |
Correct |
20 ms |
10324 KB |
Output is correct |
15 |
Correct |
4 ms |
5504 KB |
Output is correct |
16 |
Correct |
11 ms |
6144 KB |
Output is correct |
17 |
Correct |
1 ms |
512 KB |
Output is correct |
18 |
Correct |
24 ms |
11640 KB |
Output is correct |
19 |
Correct |
19 ms |
11392 KB |
Output is correct |
20 |
Correct |
20 ms |
11392 KB |
Output is correct |
21 |
Correct |
25 ms |
11648 KB |
Output is correct |
22 |
Correct |
20 ms |
11392 KB |
Output is correct |
23 |
Correct |
20 ms |
11392 KB |
Output is correct |
24 |
Correct |
24 ms |
11648 KB |
Output is correct |
25 |
Correct |
21 ms |
11392 KB |
Output is correct |
26 |
Correct |
20 ms |
11392 KB |
Output is correct |
27 |
Correct |
673 ms |
188796 KB |
Output is correct |
28 |
Correct |
20 ms |
28928 KB |
Output is correct |
29 |
Correct |
42 ms |
16376 KB |
Output is correct |
30 |
Correct |
2 ms |
896 KB |
Output is correct |
31 |
Correct |
514 ms |
154548 KB |
Output is correct |
32 |
Correct |
578 ms |
189404 KB |
Output is correct |
33 |
Correct |
556 ms |
188704 KB |
Output is correct |
34 |
Correct |
594 ms |
179016 KB |
Output is correct |
35 |
Correct |
582 ms |
189304 KB |
Output is correct |
36 |
Correct |
558 ms |
188776 KB |
Output is correct |
37 |
Correct |
696 ms |
189420 KB |
Output is correct |
38 |
Correct |
413 ms |
153640 KB |
Output is correct |
39 |
Correct |
398 ms |
153848 KB |
Output is correct |