#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define db double
using namespace std;
ll n,m;
ll pref1[3001][3001];
ll pref2[3001][3001];
string s[3001];
int main(){
cin>>n>>m;
for(ll i=1;i<=n;i++){
s[i].push_back('@');
for(ll j=1;j<=m;j++){
char c;
cin>>c;
s[i].push_back(c);
}
}
for(ll i=1;i<=n;i++){
for(ll j=1;j<=m;j++){
pref1[i][j]=pref1[i][j-1];
if(s[i][j]=='O')
pref1[i][j]++;
}
}
for(ll j=1;j<=m;j++){
for(ll i=1;i<=n;i++){
pref2[i][j]=pref2[i-1][j];
if(s[i][j]=='I')
pref2[i][j]++;
}
}
ll ans=0;
for(ll i=1;i<=n;i++){
for(ll j=1;j<=m;j++){
if(s[i][j]!='J')
continue;
ll r1=pref1[i][m]-pref1[i][j-1];
ll r2=pref2[n][j]-pref2[i-1][j];
ans+=r1*r2;
}
}
cout<<ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
1364 KB |
Output is correct |
6 |
Correct |
1 ms |
1364 KB |
Output is correct |
7 |
Correct |
2 ms |
1236 KB |
Output is correct |
8 |
Correct |
2 ms |
1364 KB |
Output is correct |
9 |
Correct |
2 ms |
1236 KB |
Output is correct |
10 |
Correct |
1 ms |
1236 KB |
Output is correct |
11 |
Correct |
2 ms |
1364 KB |
Output is correct |
12 |
Correct |
1 ms |
1236 KB |
Output is correct |
13 |
Correct |
2 ms |
1236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
1364 KB |
Output is correct |
6 |
Correct |
1 ms |
1364 KB |
Output is correct |
7 |
Correct |
2 ms |
1236 KB |
Output is correct |
8 |
Correct |
2 ms |
1364 KB |
Output is correct |
9 |
Correct |
2 ms |
1236 KB |
Output is correct |
10 |
Correct |
1 ms |
1236 KB |
Output is correct |
11 |
Correct |
2 ms |
1364 KB |
Output is correct |
12 |
Correct |
1 ms |
1236 KB |
Output is correct |
13 |
Correct |
2 ms |
1236 KB |
Output is correct |
14 |
Correct |
18 ms |
7708 KB |
Output is correct |
15 |
Correct |
2 ms |
3796 KB |
Output is correct |
16 |
Correct |
11 ms |
4820 KB |
Output is correct |
17 |
Correct |
1 ms |
524 KB |
Output is correct |
18 |
Correct |
22 ms |
8916 KB |
Output is correct |
19 |
Correct |
20 ms |
8752 KB |
Output is correct |
20 |
Correct |
20 ms |
8756 KB |
Output is correct |
21 |
Correct |
23 ms |
8892 KB |
Output is correct |
22 |
Correct |
20 ms |
8700 KB |
Output is correct |
23 |
Correct |
20 ms |
8680 KB |
Output is correct |
24 |
Correct |
23 ms |
8856 KB |
Output is correct |
25 |
Correct |
20 ms |
8708 KB |
Output is correct |
26 |
Correct |
20 ms |
8756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
1364 KB |
Output is correct |
6 |
Correct |
1 ms |
1364 KB |
Output is correct |
7 |
Correct |
2 ms |
1236 KB |
Output is correct |
8 |
Correct |
2 ms |
1364 KB |
Output is correct |
9 |
Correct |
2 ms |
1236 KB |
Output is correct |
10 |
Correct |
1 ms |
1236 KB |
Output is correct |
11 |
Correct |
2 ms |
1364 KB |
Output is correct |
12 |
Correct |
1 ms |
1236 KB |
Output is correct |
13 |
Correct |
2 ms |
1236 KB |
Output is correct |
14 |
Correct |
18 ms |
7708 KB |
Output is correct |
15 |
Correct |
2 ms |
3796 KB |
Output is correct |
16 |
Correct |
11 ms |
4820 KB |
Output is correct |
17 |
Correct |
1 ms |
524 KB |
Output is correct |
18 |
Correct |
22 ms |
8916 KB |
Output is correct |
19 |
Correct |
20 ms |
8752 KB |
Output is correct |
20 |
Correct |
20 ms |
8756 KB |
Output is correct |
21 |
Correct |
23 ms |
8892 KB |
Output is correct |
22 |
Correct |
20 ms |
8700 KB |
Output is correct |
23 |
Correct |
20 ms |
8680 KB |
Output is correct |
24 |
Correct |
23 ms |
8856 KB |
Output is correct |
25 |
Correct |
20 ms |
8708 KB |
Output is correct |
26 |
Correct |
20 ms |
8756 KB |
Output is correct |
27 |
Correct |
777 ms |
152720 KB |
Output is correct |
28 |
Correct |
14 ms |
19540 KB |
Output is correct |
29 |
Correct |
49 ms |
13664 KB |
Output is correct |
30 |
Correct |
3 ms |
852 KB |
Output is correct |
31 |
Correct |
573 ms |
127520 KB |
Output is correct |
32 |
Correct |
785 ms |
152880 KB |
Output is correct |
33 |
Correct |
772 ms |
152532 KB |
Output is correct |
34 |
Correct |
683 ms |
147916 KB |
Output is correct |
35 |
Correct |
809 ms |
152904 KB |
Output is correct |
36 |
Correct |
786 ms |
152404 KB |
Output is correct |
37 |
Correct |
843 ms |
152904 KB |
Output is correct |
38 |
Correct |
570 ms |
127140 KB |
Output is correct |
39 |
Correct |
560 ms |
126932 KB |
Output is correct |