#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ll = long long;
using pi = pair<int,int>;
#define ST first
#define ND second
#define PB push_back
const int nax = 3000 + 10;
int n, m;
int s1[nax][nax], s2[nax][nax];
string s[nax];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for(int i = 1; i <= n; ++i) {
cin >> s[i];
s[i] = "#" + s[i];
}
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= m; ++j) {
s1[i][j] = s1[i][j - 1] + (s[i][j] == 'O');
s2[i][j] = s2[i - 1][j] + (s[i][j] == 'I');
}
}
ll ans = 0;
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= m; ++j) {
if(s[i][j] == 'J') {
ans += ((ll)(s1[i][m] - s1[i][j]) * (s2[n][j] - s2[i][j]));
}
}
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Correct |
1 ms |
512 KB |
Output is correct |
3 |
Correct |
1 ms |
436 KB |
Output is correct |
4 |
Correct |
1 ms |
512 KB |
Output is correct |
5 |
Correct |
1 ms |
1280 KB |
Output is correct |
6 |
Correct |
1 ms |
1280 KB |
Output is correct |
7 |
Correct |
1 ms |
1280 KB |
Output is correct |
8 |
Correct |
1 ms |
1280 KB |
Output is correct |
9 |
Correct |
1 ms |
1280 KB |
Output is correct |
10 |
Correct |
2 ms |
1280 KB |
Output is correct |
11 |
Correct |
1 ms |
1280 KB |
Output is correct |
12 |
Correct |
1 ms |
1280 KB |
Output is correct |
13 |
Correct |
1 ms |
1280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Correct |
1 ms |
512 KB |
Output is correct |
3 |
Correct |
1 ms |
436 KB |
Output is correct |
4 |
Correct |
1 ms |
512 KB |
Output is correct |
5 |
Correct |
1 ms |
1280 KB |
Output is correct |
6 |
Correct |
1 ms |
1280 KB |
Output is correct |
7 |
Correct |
1 ms |
1280 KB |
Output is correct |
8 |
Correct |
1 ms |
1280 KB |
Output is correct |
9 |
Correct |
1 ms |
1280 KB |
Output is correct |
10 |
Correct |
2 ms |
1280 KB |
Output is correct |
11 |
Correct |
1 ms |
1280 KB |
Output is correct |
12 |
Correct |
1 ms |
1280 KB |
Output is correct |
13 |
Correct |
1 ms |
1280 KB |
Output is correct |
14 |
Correct |
6 ms |
6272 KB |
Output is correct |
15 |
Correct |
3 ms |
3840 KB |
Output is correct |
16 |
Correct |
4 ms |
3840 KB |
Output is correct |
17 |
Correct |
1 ms |
512 KB |
Output is correct |
18 |
Correct |
7 ms |
6912 KB |
Output is correct |
19 |
Correct |
6 ms |
6784 KB |
Output is correct |
20 |
Correct |
6 ms |
6784 KB |
Output is correct |
21 |
Correct |
7 ms |
6912 KB |
Output is correct |
22 |
Correct |
6 ms |
6784 KB |
Output is correct |
23 |
Correct |
6 ms |
6784 KB |
Output is correct |
24 |
Correct |
7 ms |
6912 KB |
Output is correct |
25 |
Correct |
6 ms |
6784 KB |
Output is correct |
26 |
Correct |
6 ms |
6784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Correct |
1 ms |
512 KB |
Output is correct |
3 |
Correct |
1 ms |
436 KB |
Output is correct |
4 |
Correct |
1 ms |
512 KB |
Output is correct |
5 |
Correct |
1 ms |
1280 KB |
Output is correct |
6 |
Correct |
1 ms |
1280 KB |
Output is correct |
7 |
Correct |
1 ms |
1280 KB |
Output is correct |
8 |
Correct |
1 ms |
1280 KB |
Output is correct |
9 |
Correct |
1 ms |
1280 KB |
Output is correct |
10 |
Correct |
2 ms |
1280 KB |
Output is correct |
11 |
Correct |
1 ms |
1280 KB |
Output is correct |
12 |
Correct |
1 ms |
1280 KB |
Output is correct |
13 |
Correct |
1 ms |
1280 KB |
Output is correct |
14 |
Correct |
6 ms |
6272 KB |
Output is correct |
15 |
Correct |
3 ms |
3840 KB |
Output is correct |
16 |
Correct |
4 ms |
3840 KB |
Output is correct |
17 |
Correct |
1 ms |
512 KB |
Output is correct |
18 |
Correct |
7 ms |
6912 KB |
Output is correct |
19 |
Correct |
6 ms |
6784 KB |
Output is correct |
20 |
Correct |
6 ms |
6784 KB |
Output is correct |
21 |
Correct |
7 ms |
6912 KB |
Output is correct |
22 |
Correct |
6 ms |
6784 KB |
Output is correct |
23 |
Correct |
6 ms |
6784 KB |
Output is correct |
24 |
Correct |
7 ms |
6912 KB |
Output is correct |
25 |
Correct |
6 ms |
6784 KB |
Output is correct |
26 |
Correct |
6 ms |
6784 KB |
Output is correct |
27 |
Correct |
124 ms |
87852 KB |
Output is correct |
28 |
Correct |
13 ms |
19328 KB |
Output is correct |
29 |
Correct |
9 ms |
7808 KB |
Output is correct |
30 |
Correct |
1 ms |
768 KB |
Output is correct |
31 |
Correct |
98 ms |
71800 KB |
Output is correct |
32 |
Correct |
100 ms |
88696 KB |
Output is correct |
33 |
Correct |
98 ms |
88568 KB |
Output is correct |
34 |
Correct |
112 ms |
82936 KB |
Output is correct |
35 |
Correct |
106 ms |
88824 KB |
Output is correct |
36 |
Correct |
96 ms |
88568 KB |
Output is correct |
37 |
Correct |
132 ms |
88872 KB |
Output is correct |
38 |
Correct |
75 ms |
71544 KB |
Output is correct |
39 |
Correct |
73 ms |
71288 KB |
Output is correct |