#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int N = 3007;
int n, m, row[N][N], col[N][N];
long long ans = 0;
string s[N];
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> m;
for(int i = 1; i <= n; i++){
cin >> s[i];
for(int j = 1; j <= m; j++){
row[i][j] = row[i][j - 1];
if(s[i][j - 1] == 'O') row[i][j]++;
else if(s[i][j - 1] == 'I') col[j][i]++;
}
}
for(int j = 1; j <= m; j++){
for(int i = 1; i <= n; i++){
col[j][i] += col[j][i - 1];
}
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
if(s[i][j - 1] != 'J') continue;
ans += 1LL * (row[i][m] - row[i][j]) * (col[j][n] - col[j][i]);
}
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
3 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
512 KB |
Output is correct |
4 |
Correct |
3 ms |
512 KB |
Output is correct |
5 |
Correct |
3 ms |
1280 KB |
Output is correct |
6 |
Correct |
5 ms |
1280 KB |
Output is correct |
7 |
Correct |
3 ms |
1280 KB |
Output is correct |
8 |
Correct |
4 ms |
1408 KB |
Output is correct |
9 |
Correct |
4 ms |
1280 KB |
Output is correct |
10 |
Correct |
3 ms |
1280 KB |
Output is correct |
11 |
Correct |
3 ms |
1380 KB |
Output is correct |
12 |
Correct |
3 ms |
1280 KB |
Output is correct |
13 |
Correct |
3 ms |
1280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
3 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
512 KB |
Output is correct |
4 |
Correct |
3 ms |
512 KB |
Output is correct |
5 |
Correct |
3 ms |
1280 KB |
Output is correct |
6 |
Correct |
5 ms |
1280 KB |
Output is correct |
7 |
Correct |
3 ms |
1280 KB |
Output is correct |
8 |
Correct |
4 ms |
1408 KB |
Output is correct |
9 |
Correct |
4 ms |
1280 KB |
Output is correct |
10 |
Correct |
3 ms |
1280 KB |
Output is correct |
11 |
Correct |
3 ms |
1380 KB |
Output is correct |
12 |
Correct |
3 ms |
1280 KB |
Output is correct |
13 |
Correct |
3 ms |
1280 KB |
Output is correct |
14 |
Correct |
14 ms |
5888 KB |
Output is correct |
15 |
Correct |
5 ms |
2304 KB |
Output is correct |
16 |
Correct |
9 ms |
4736 KB |
Output is correct |
17 |
Correct |
4 ms |
1664 KB |
Output is correct |
18 |
Correct |
16 ms |
6912 KB |
Output is correct |
19 |
Correct |
13 ms |
6756 KB |
Output is correct |
20 |
Correct |
12 ms |
6784 KB |
Output is correct |
21 |
Correct |
12 ms |
6912 KB |
Output is correct |
22 |
Correct |
12 ms |
6784 KB |
Output is correct |
23 |
Correct |
11 ms |
6784 KB |
Output is correct |
24 |
Correct |
13 ms |
6912 KB |
Output is correct |
25 |
Correct |
11 ms |
6784 KB |
Output is correct |
26 |
Correct |
10 ms |
6784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
3 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
512 KB |
Output is correct |
4 |
Correct |
3 ms |
512 KB |
Output is correct |
5 |
Correct |
3 ms |
1280 KB |
Output is correct |
6 |
Correct |
5 ms |
1280 KB |
Output is correct |
7 |
Correct |
3 ms |
1280 KB |
Output is correct |
8 |
Correct |
4 ms |
1408 KB |
Output is correct |
9 |
Correct |
4 ms |
1280 KB |
Output is correct |
10 |
Correct |
3 ms |
1280 KB |
Output is correct |
11 |
Correct |
3 ms |
1380 KB |
Output is correct |
12 |
Correct |
3 ms |
1280 KB |
Output is correct |
13 |
Correct |
3 ms |
1280 KB |
Output is correct |
14 |
Correct |
14 ms |
5888 KB |
Output is correct |
15 |
Correct |
5 ms |
2304 KB |
Output is correct |
16 |
Correct |
9 ms |
4736 KB |
Output is correct |
17 |
Correct |
4 ms |
1664 KB |
Output is correct |
18 |
Correct |
16 ms |
6912 KB |
Output is correct |
19 |
Correct |
13 ms |
6756 KB |
Output is correct |
20 |
Correct |
12 ms |
6784 KB |
Output is correct |
21 |
Correct |
12 ms |
6912 KB |
Output is correct |
22 |
Correct |
12 ms |
6784 KB |
Output is correct |
23 |
Correct |
11 ms |
6784 KB |
Output is correct |
24 |
Correct |
13 ms |
6912 KB |
Output is correct |
25 |
Correct |
11 ms |
6784 KB |
Output is correct |
26 |
Correct |
10 ms |
6784 KB |
Output is correct |
27 |
Correct |
271 ms |
85276 KB |
Output is correct |
28 |
Correct |
14 ms |
10112 KB |
Output is correct |
29 |
Correct |
25 ms |
17408 KB |
Output is correct |
30 |
Correct |
10 ms |
9856 KB |
Output is correct |
31 |
Correct |
247 ms |
71160 KB |
Output is correct |
32 |
Correct |
185 ms |
87032 KB |
Output is correct |
33 |
Correct |
193 ms |
87160 KB |
Output is correct |
34 |
Correct |
237 ms |
78072 KB |
Output is correct |
35 |
Correct |
217 ms |
86960 KB |
Output is correct |
36 |
Correct |
201 ms |
87036 KB |
Output is correct |
37 |
Correct |
284 ms |
87544 KB |
Output is correct |
38 |
Correct |
133 ms |
70844 KB |
Output is correct |
39 |
Correct |
146 ms |
70916 KB |
Output is correct |