#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define F first
#define S second
#define endl "\n"
const int INF = 1e9+10;
const int MOD = 1e9+7;
int n, m;
string s[3030];
int sumi[3030][3030], sumo[3030][3030];
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
for(int i = 0; i < n; i++) {
cin >> s[i];
}
for(int i = 0; i < n; i++) {
int at = 0;
for(int j = 0; j < m; j++) {
if(s[i][j] == 'O') at++;
sumo[i][j] = at;
}
}
for(int i = 0; i < m; i++) {
int at = 0;
for(int j = 0; j < n; j++) {
if(s[j][i] == 'I') at++;
sumi[j][i] = at;
}
}
int resp = 0;
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
if(s[i][j] == 'J') {
int ci = sumi[n-1][j] - sumi[i][j];
int co = sumo[i][m-1] - sumo[i][j];
resp += ci * co;
}
}
}
cout << resp << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
1364 KB |
Output is correct |
6 |
Correct |
1 ms |
1364 KB |
Output is correct |
7 |
Correct |
1 ms |
1236 KB |
Output is correct |
8 |
Correct |
1 ms |
1364 KB |
Output is correct |
9 |
Correct |
1 ms |
1364 KB |
Output is correct |
10 |
Correct |
1 ms |
1236 KB |
Output is correct |
11 |
Correct |
1 ms |
1364 KB |
Output is correct |
12 |
Correct |
1 ms |
1364 KB |
Output is correct |
13 |
Correct |
1 ms |
1236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
1364 KB |
Output is correct |
6 |
Correct |
1 ms |
1364 KB |
Output is correct |
7 |
Correct |
1 ms |
1236 KB |
Output is correct |
8 |
Correct |
1 ms |
1364 KB |
Output is correct |
9 |
Correct |
1 ms |
1364 KB |
Output is correct |
10 |
Correct |
1 ms |
1236 KB |
Output is correct |
11 |
Correct |
1 ms |
1364 KB |
Output is correct |
12 |
Correct |
1 ms |
1364 KB |
Output is correct |
13 |
Correct |
1 ms |
1236 KB |
Output is correct |
14 |
Correct |
5 ms |
7848 KB |
Output is correct |
15 |
Correct |
2 ms |
3796 KB |
Output is correct |
16 |
Correct |
3 ms |
4772 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
6 ms |
8864 KB |
Output is correct |
19 |
Correct |
5 ms |
8660 KB |
Output is correct |
20 |
Correct |
5 ms |
8580 KB |
Output is correct |
21 |
Correct |
6 ms |
8876 KB |
Output is correct |
22 |
Correct |
5 ms |
8660 KB |
Output is correct |
23 |
Correct |
5 ms |
8612 KB |
Output is correct |
24 |
Correct |
6 ms |
8864 KB |
Output is correct |
25 |
Correct |
5 ms |
8660 KB |
Output is correct |
26 |
Correct |
5 ms |
8660 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
1364 KB |
Output is correct |
6 |
Correct |
1 ms |
1364 KB |
Output is correct |
7 |
Correct |
1 ms |
1236 KB |
Output is correct |
8 |
Correct |
1 ms |
1364 KB |
Output is correct |
9 |
Correct |
1 ms |
1364 KB |
Output is correct |
10 |
Correct |
1 ms |
1236 KB |
Output is correct |
11 |
Correct |
1 ms |
1364 KB |
Output is correct |
12 |
Correct |
1 ms |
1364 KB |
Output is correct |
13 |
Correct |
1 ms |
1236 KB |
Output is correct |
14 |
Correct |
5 ms |
7848 KB |
Output is correct |
15 |
Correct |
2 ms |
3796 KB |
Output is correct |
16 |
Correct |
3 ms |
4772 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
6 ms |
8864 KB |
Output is correct |
19 |
Correct |
5 ms |
8660 KB |
Output is correct |
20 |
Correct |
5 ms |
8580 KB |
Output is correct |
21 |
Correct |
6 ms |
8876 KB |
Output is correct |
22 |
Correct |
5 ms |
8660 KB |
Output is correct |
23 |
Correct |
5 ms |
8612 KB |
Output is correct |
24 |
Correct |
6 ms |
8864 KB |
Output is correct |
25 |
Correct |
5 ms |
8660 KB |
Output is correct |
26 |
Correct |
5 ms |
8660 KB |
Output is correct |
27 |
Correct |
243 ms |
160188 KB |
Output is correct |
28 |
Correct |
9 ms |
19540 KB |
Output is correct |
29 |
Correct |
10 ms |
13908 KB |
Output is correct |
30 |
Correct |
1 ms |
852 KB |
Output is correct |
31 |
Correct |
198 ms |
130900 KB |
Output is correct |
32 |
Correct |
222 ms |
161020 KB |
Output is correct |
33 |
Correct |
216 ms |
160632 KB |
Output is correct |
34 |
Correct |
221 ms |
151752 KB |
Output is correct |
35 |
Correct |
229 ms |
161080 KB |
Output is correct |
36 |
Correct |
244 ms |
160688 KB |
Output is correct |
37 |
Correct |
258 ms |
161204 KB |
Output is correct |
38 |
Correct |
155 ms |
129988 KB |
Output is correct |
39 |
Correct |
170 ms |
130504 KB |
Output is correct |