#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
int h, w; cin >> h >> w;
vector<vector<char>> a(h, vector<char> (w));
for (int i = 0; i < h; i++){
string s; cin >> s;
for (int j = 0; j < w; j++){
a[i][j] = s[j];
}
}
vector<vector<int>> col(h, vector<int> (w));
vector<vector<int>> fil(h, vector<int> (w));
for (int i = 0; i < h; i++){
for (int j = 0; j < w; j++){
if (j == 0) fil[i][j] += (a[i][j] == 'O');
else {
fil[i][j] = (a[i][j] == 'O');
fil[i][j] += fil[i][j - 1];
}
}
}
for (int i = 0; i < w; i++){
for (int j = 0; j < h; j++){
if (j == 0)col[j][i] = (a[j][i] == 'I');
else {
col[j][i] = (a[j][i] == 'I');
col[j][i] += col[j-1][i];
}
}
}
int ans = 0;
for (int i = 0; i < h; i++){
for (int j = 0; j < w; j++){
if (a[i][j] == 'J') ans += (fil[i][w - 1] - fil[i][j]) * (col[h - 1][j] - col[i][j]);
}
}
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
856 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
600 KB |
Output is correct |
11 |
Correct |
1 ms |
600 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
856 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
600 KB |
Output is correct |
11 |
Correct |
1 ms |
600 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
14 |
Correct |
6 ms |
3676 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
2652 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
7 ms |
4700 KB |
Output is correct |
19 |
Correct |
6 ms |
4640 KB |
Output is correct |
20 |
Correct |
8 ms |
4696 KB |
Output is correct |
21 |
Correct |
7 ms |
4788 KB |
Output is correct |
22 |
Correct |
6 ms |
4700 KB |
Output is correct |
23 |
Correct |
7 ms |
4708 KB |
Output is correct |
24 |
Correct |
8 ms |
4696 KB |
Output is correct |
25 |
Correct |
6 ms |
4700 KB |
Output is correct |
26 |
Correct |
6 ms |
4768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
856 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
600 KB |
Output is correct |
11 |
Correct |
1 ms |
600 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
14 |
Correct |
6 ms |
3676 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
2652 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
7 ms |
4700 KB |
Output is correct |
19 |
Correct |
6 ms |
4640 KB |
Output is correct |
20 |
Correct |
8 ms |
4696 KB |
Output is correct |
21 |
Correct |
7 ms |
4788 KB |
Output is correct |
22 |
Correct |
6 ms |
4700 KB |
Output is correct |
23 |
Correct |
7 ms |
4708 KB |
Output is correct |
24 |
Correct |
8 ms |
4696 KB |
Output is correct |
25 |
Correct |
6 ms |
4700 KB |
Output is correct |
26 |
Correct |
6 ms |
4768 KB |
Output is correct |
27 |
Correct |
280 ms |
150352 KB |
Output is correct |
28 |
Correct |
2 ms |
1116 KB |
Output is correct |
29 |
Correct |
18 ms |
11816 KB |
Output is correct |
30 |
Correct |
1 ms |
604 KB |
Output is correct |
31 |
Correct |
208 ms |
110556 KB |
Output is correct |
32 |
Correct |
279 ms |
158012 KB |
Output is correct |
33 |
Correct |
270 ms |
158548 KB |
Output is correct |
34 |
Correct |
227 ms |
128448 KB |
Output is correct |
35 |
Correct |
281 ms |
158036 KB |
Output is correct |
36 |
Correct |
257 ms |
158532 KB |
Output is correct |
37 |
Correct |
289 ms |
159200 KB |
Output is correct |
38 |
Correct |
185 ms |
109748 KB |
Output is correct |
39 |
Correct |
178 ms |
110160 KB |
Output is correct |