/**
__author__ : FireGhost
problems_ID: JOI19_ho_t1
*/
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
const int N = 3000 + 3;
const int MOD = 1e9 + 7;
int n, m, row_prf[N][N], col_prf[N][N];
char c[N][N];
void solve() {
cin >> n >> m;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
cin >> c[i][j];
row_prf[i][j] = row_prf[i][j - 1] + (c[i][j] == 'O');
col_prf[i][j] = col_prf[i - 1][j] + (c[i][j] == 'I');
}
}
ll ans = 0;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
if (c[i][j] == 'J')
ans += (row_prf[i][m] - row_prf[i][j]) * (col_prf[n][j] - col_prf[i][j]);
}
}
cout << ans;
}
int main() {
cin.tie(NULL);
ios_base::sync_with_stdio(false);
int t = 1;
while (t--)
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
1484 KB |
Output is correct |
6 |
Correct |
1 ms |
1484 KB |
Output is correct |
7 |
Correct |
1 ms |
1324 KB |
Output is correct |
8 |
Correct |
1 ms |
1484 KB |
Output is correct |
9 |
Correct |
1 ms |
1484 KB |
Output is correct |
10 |
Correct |
2 ms |
1356 KB |
Output is correct |
11 |
Correct |
1 ms |
1484 KB |
Output is correct |
12 |
Correct |
1 ms |
1484 KB |
Output is correct |
13 |
Correct |
1 ms |
1356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
1484 KB |
Output is correct |
6 |
Correct |
1 ms |
1484 KB |
Output is correct |
7 |
Correct |
1 ms |
1324 KB |
Output is correct |
8 |
Correct |
1 ms |
1484 KB |
Output is correct |
9 |
Correct |
1 ms |
1484 KB |
Output is correct |
10 |
Correct |
2 ms |
1356 KB |
Output is correct |
11 |
Correct |
1 ms |
1484 KB |
Output is correct |
12 |
Correct |
1 ms |
1484 KB |
Output is correct |
13 |
Correct |
1 ms |
1356 KB |
Output is correct |
14 |
Correct |
7 ms |
7372 KB |
Output is correct |
15 |
Correct |
4 ms |
4988 KB |
Output is correct |
16 |
Correct |
4 ms |
4300 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
10 ms |
8020 KB |
Output is correct |
19 |
Correct |
8 ms |
7884 KB |
Output is correct |
20 |
Correct |
8 ms |
7856 KB |
Output is correct |
21 |
Correct |
9 ms |
7936 KB |
Output is correct |
22 |
Correct |
8 ms |
7884 KB |
Output is correct |
23 |
Correct |
8 ms |
7744 KB |
Output is correct |
24 |
Correct |
9 ms |
8016 KB |
Output is correct |
25 |
Correct |
8 ms |
7836 KB |
Output is correct |
26 |
Correct |
9 ms |
7756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
1484 KB |
Output is correct |
6 |
Correct |
1 ms |
1484 KB |
Output is correct |
7 |
Correct |
1 ms |
1324 KB |
Output is correct |
8 |
Correct |
1 ms |
1484 KB |
Output is correct |
9 |
Correct |
1 ms |
1484 KB |
Output is correct |
10 |
Correct |
2 ms |
1356 KB |
Output is correct |
11 |
Correct |
1 ms |
1484 KB |
Output is correct |
12 |
Correct |
1 ms |
1484 KB |
Output is correct |
13 |
Correct |
1 ms |
1356 KB |
Output is correct |
14 |
Correct |
7 ms |
7372 KB |
Output is correct |
15 |
Correct |
4 ms |
4988 KB |
Output is correct |
16 |
Correct |
4 ms |
4300 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
10 ms |
8020 KB |
Output is correct |
19 |
Correct |
8 ms |
7884 KB |
Output is correct |
20 |
Correct |
8 ms |
7856 KB |
Output is correct |
21 |
Correct |
9 ms |
7936 KB |
Output is correct |
22 |
Correct |
8 ms |
7884 KB |
Output is correct |
23 |
Correct |
8 ms |
7744 KB |
Output is correct |
24 |
Correct |
9 ms |
8016 KB |
Output is correct |
25 |
Correct |
8 ms |
7836 KB |
Output is correct |
26 |
Correct |
9 ms |
7756 KB |
Output is correct |
27 |
Correct |
220 ms |
81360 KB |
Output is correct |
28 |
Correct |
12 ms |
25932 KB |
Output is correct |
29 |
Correct |
15 ms |
7784 KB |
Output is correct |
30 |
Correct |
1 ms |
588 KB |
Output is correct |
31 |
Correct |
146 ms |
68148 KB |
Output is correct |
32 |
Correct |
175 ms |
81384 KB |
Output is correct |
33 |
Correct |
172 ms |
81092 KB |
Output is correct |
34 |
Correct |
187 ms |
78660 KB |
Output is correct |
35 |
Correct |
179 ms |
81396 KB |
Output is correct |
36 |
Correct |
176 ms |
81120 KB |
Output is correct |
37 |
Correct |
216 ms |
81356 KB |
Output is correct |
38 |
Correct |
138 ms |
68160 KB |
Output is correct |
39 |
Correct |
122 ms |
67900 KB |
Output is correct |