#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define pb push_back
const int N=3e3+2;
char a[N][N];
int psi[N][N];
int pso[N][N];
signed main(){
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>a[i][j];
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
pso[i][j]=pso[i][j-1];
if(a[i][j]=='O')pso[i][j]++;
}
}
for(int j=1;j<=m;j++){
for(int i=1;i<=n;i++){
psi[i][j]=psi[i-1][j];
if(a[i][j]=='I')psi[i][j]++;
}
}
int ans=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(a[i][j]=='J'){
ans+= (pso[i][m]-pso[i][j])*(psi[n][j]-psi[i][j]);
}
}
}
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
2 ms |
5212 KB |
Output is correct |
6 |
Correct |
1 ms |
5212 KB |
Output is correct |
7 |
Correct |
1 ms |
5212 KB |
Output is correct |
8 |
Correct |
1 ms |
5212 KB |
Output is correct |
9 |
Correct |
2 ms |
5212 KB |
Output is correct |
10 |
Correct |
1 ms |
5212 KB |
Output is correct |
11 |
Correct |
1 ms |
5212 KB |
Output is correct |
12 |
Correct |
1 ms |
5212 KB |
Output is correct |
13 |
Correct |
1 ms |
5212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
2 ms |
5212 KB |
Output is correct |
6 |
Correct |
1 ms |
5212 KB |
Output is correct |
7 |
Correct |
1 ms |
5212 KB |
Output is correct |
8 |
Correct |
1 ms |
5212 KB |
Output is correct |
9 |
Correct |
2 ms |
5212 KB |
Output is correct |
10 |
Correct |
1 ms |
5212 KB |
Output is correct |
11 |
Correct |
1 ms |
5212 KB |
Output is correct |
12 |
Correct |
1 ms |
5212 KB |
Output is correct |
13 |
Correct |
1 ms |
5212 KB |
Output is correct |
14 |
Correct |
12 ms |
23644 KB |
Output is correct |
15 |
Correct |
3 ms |
16580 KB |
Output is correct |
16 |
Correct |
7 ms |
14684 KB |
Output is correct |
17 |
Correct |
1 ms |
2392 KB |
Output is correct |
18 |
Correct |
18 ms |
24156 KB |
Output is correct |
19 |
Correct |
13 ms |
24156 KB |
Output is correct |
20 |
Correct |
13 ms |
22104 KB |
Output is correct |
21 |
Correct |
18 ms |
24408 KB |
Output is correct |
22 |
Correct |
13 ms |
24156 KB |
Output is correct |
23 |
Correct |
13 ms |
22108 KB |
Output is correct |
24 |
Correct |
15 ms |
24156 KB |
Output is correct |
25 |
Correct |
13 ms |
23980 KB |
Output is correct |
26 |
Correct |
13 ms |
22108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
2 ms |
5212 KB |
Output is correct |
6 |
Correct |
1 ms |
5212 KB |
Output is correct |
7 |
Correct |
1 ms |
5212 KB |
Output is correct |
8 |
Correct |
1 ms |
5212 KB |
Output is correct |
9 |
Correct |
2 ms |
5212 KB |
Output is correct |
10 |
Correct |
1 ms |
5212 KB |
Output is correct |
11 |
Correct |
1 ms |
5212 KB |
Output is correct |
12 |
Correct |
1 ms |
5212 KB |
Output is correct |
13 |
Correct |
1 ms |
5212 KB |
Output is correct |
14 |
Correct |
12 ms |
23644 KB |
Output is correct |
15 |
Correct |
3 ms |
16580 KB |
Output is correct |
16 |
Correct |
7 ms |
14684 KB |
Output is correct |
17 |
Correct |
1 ms |
2392 KB |
Output is correct |
18 |
Correct |
18 ms |
24156 KB |
Output is correct |
19 |
Correct |
13 ms |
24156 KB |
Output is correct |
20 |
Correct |
13 ms |
22104 KB |
Output is correct |
21 |
Correct |
18 ms |
24408 KB |
Output is correct |
22 |
Correct |
13 ms |
24156 KB |
Output is correct |
23 |
Correct |
13 ms |
22108 KB |
Output is correct |
24 |
Correct |
15 ms |
24156 KB |
Output is correct |
25 |
Correct |
13 ms |
23980 KB |
Output is correct |
26 |
Correct |
13 ms |
22108 KB |
Output is correct |
27 |
Correct |
432 ms |
158676 KB |
Output is correct |
28 |
Correct |
11 ms |
71772 KB |
Output is correct |
29 |
Correct |
32 ms |
18984 KB |
Output is correct |
30 |
Correct |
2 ms |
2908 KB |
Output is correct |
31 |
Correct |
307 ms |
133812 KB |
Output is correct |
32 |
Correct |
404 ms |
159012 KB |
Output is correct |
33 |
Correct |
411 ms |
158876 KB |
Output is correct |
34 |
Correct |
362 ms |
156580 KB |
Output is correct |
35 |
Correct |
388 ms |
158816 KB |
Output is correct |
36 |
Correct |
405 ms |
159012 KB |
Output is correct |
37 |
Correct |
447 ms |
159092 KB |
Output is correct |
38 |
Correct |
270 ms |
132776 KB |
Output is correct |
39 |
Correct |
269 ms |
133708 KB |
Output is correct |