#include<bits/stdc++.h>
using namespace std;
const int N=3005;
int n,m,sRow[N][N][2],sCol[N][N][2];
char a[N][N];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin>>n>>m;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
cin>>a[i][j];
for(int k=0;k<2;k++)
{
sRow[i][j][k]=sRow[i][j-1][k];
sCol[i][j][k]=sCol[i-1][j][k];
}
if(a[i][j]=='O') sRow[i][j][0]++,sCol[i][j][0]++;
if(a[i][j]=='I') sRow[i][j][1]++,sCol[i][j][1]++;
}
}
long long res=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if(a[i][j]!='J') continue;
int numO=sRow[i][m][0]-sRow[i][j][0];
int numI=sCol[n][j][1]-sCol[i][j][1];
res+=1ll*numI*numO;
}
}
cout<<res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
512 KB |
Output is correct |
5 |
Correct |
2 ms |
1560 KB |
Output is correct |
6 |
Correct |
2 ms |
1664 KB |
Output is correct |
7 |
Correct |
1 ms |
1536 KB |
Output is correct |
8 |
Correct |
2 ms |
1664 KB |
Output is correct |
9 |
Correct |
1 ms |
1536 KB |
Output is correct |
10 |
Correct |
2 ms |
1536 KB |
Output is correct |
11 |
Correct |
2 ms |
1664 KB |
Output is correct |
12 |
Correct |
2 ms |
1536 KB |
Output is correct |
13 |
Correct |
2 ms |
1536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
512 KB |
Output is correct |
5 |
Correct |
2 ms |
1560 KB |
Output is correct |
6 |
Correct |
2 ms |
1664 KB |
Output is correct |
7 |
Correct |
1 ms |
1536 KB |
Output is correct |
8 |
Correct |
2 ms |
1664 KB |
Output is correct |
9 |
Correct |
1 ms |
1536 KB |
Output is correct |
10 |
Correct |
2 ms |
1536 KB |
Output is correct |
11 |
Correct |
2 ms |
1664 KB |
Output is correct |
12 |
Correct |
2 ms |
1536 KB |
Output is correct |
13 |
Correct |
2 ms |
1536 KB |
Output is correct |
14 |
Correct |
14 ms |
9088 KB |
Output is correct |
15 |
Correct |
4 ms |
5120 KB |
Output is correct |
16 |
Correct |
6 ms |
5376 KB |
Output is correct |
17 |
Correct |
1 ms |
512 KB |
Output is correct |
18 |
Correct |
16 ms |
9984 KB |
Output is correct |
19 |
Correct |
13 ms |
9856 KB |
Output is correct |
20 |
Correct |
12 ms |
9856 KB |
Output is correct |
21 |
Correct |
15 ms |
9984 KB |
Output is correct |
22 |
Correct |
12 ms |
9856 KB |
Output is correct |
23 |
Correct |
12 ms |
9856 KB |
Output is correct |
24 |
Correct |
15 ms |
9984 KB |
Output is correct |
25 |
Correct |
12 ms |
9856 KB |
Output is correct |
26 |
Correct |
12 ms |
9856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
512 KB |
Output is correct |
5 |
Correct |
2 ms |
1560 KB |
Output is correct |
6 |
Correct |
2 ms |
1664 KB |
Output is correct |
7 |
Correct |
1 ms |
1536 KB |
Output is correct |
8 |
Correct |
2 ms |
1664 KB |
Output is correct |
9 |
Correct |
1 ms |
1536 KB |
Output is correct |
10 |
Correct |
2 ms |
1536 KB |
Output is correct |
11 |
Correct |
2 ms |
1664 KB |
Output is correct |
12 |
Correct |
2 ms |
1536 KB |
Output is correct |
13 |
Correct |
2 ms |
1536 KB |
Output is correct |
14 |
Correct |
14 ms |
9088 KB |
Output is correct |
15 |
Correct |
4 ms |
5120 KB |
Output is correct |
16 |
Correct |
6 ms |
5376 KB |
Output is correct |
17 |
Correct |
1 ms |
512 KB |
Output is correct |
18 |
Correct |
16 ms |
9984 KB |
Output is correct |
19 |
Correct |
13 ms |
9856 KB |
Output is correct |
20 |
Correct |
12 ms |
9856 KB |
Output is correct |
21 |
Correct |
15 ms |
9984 KB |
Output is correct |
22 |
Correct |
12 ms |
9856 KB |
Output is correct |
23 |
Correct |
12 ms |
9856 KB |
Output is correct |
24 |
Correct |
15 ms |
9984 KB |
Output is correct |
25 |
Correct |
12 ms |
9856 KB |
Output is correct |
26 |
Correct |
12 ms |
9856 KB |
Output is correct |
27 |
Correct |
369 ms |
158584 KB |
Output is correct |
28 |
Correct |
19 ms |
26368 KB |
Output is correct |
29 |
Correct |
22 ms |
13952 KB |
Output is correct |
30 |
Correct |
2 ms |
896 KB |
Output is correct |
31 |
Correct |
272 ms |
131448 KB |
Output is correct |
32 |
Correct |
296 ms |
159100 KB |
Output is correct |
33 |
Correct |
265 ms |
158568 KB |
Output is correct |
34 |
Correct |
317 ms |
152568 KB |
Output is correct |
35 |
Correct |
314 ms |
159096 KB |
Output is correct |
36 |
Correct |
257 ms |
158584 KB |
Output is correct |
37 |
Correct |
378 ms |
159096 KB |
Output is correct |
38 |
Correct |
220 ms |
130936 KB |
Output is correct |
39 |
Correct |
198 ms |
130936 KB |
Output is correct |