#include <iostream>
#include <queue>
#include <algorithm>
#include <utility>
#include <vector>
int h, w;
char board[3005][3005];
int countorb[3005][3005], countingot[3005][3005];
int main()
{
std::ios_base::sync_with_stdio(false);
std::cin.tie(0);
std::cout.tie(0);
std::cin >> h >> w;
for(int i = 1; i <= h; i++)
{
for(int j = 1; j <= w; j++)
{
std::cin >> board[i][j];
countorb[i][j] = countorb[i][j - 1] + (board[i][j] == 'O');
countingot[i][j] = countingot[i - 1][j] + (board[i][j] == 'I');
}
}
long long ans = 0;
for(int i = 1; i <= h; i++)
{
for(int j = 1; j <= w; j++)
{
if(board[i][j] == 'J')
{
ans += 1ll * (countorb[i][w] - countorb[i][j]) * (countingot[h][j] - countingot[i][j]);
}
}
}
std::cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
1 ms |
1536 KB |
Output is correct |
6 |
Correct |
1 ms |
1516 KB |
Output is correct |
7 |
Correct |
1 ms |
1388 KB |
Output is correct |
8 |
Correct |
1 ms |
1516 KB |
Output is correct |
9 |
Correct |
1 ms |
1516 KB |
Output is correct |
10 |
Correct |
1 ms |
1388 KB |
Output is correct |
11 |
Correct |
1 ms |
1532 KB |
Output is correct |
12 |
Correct |
1 ms |
1516 KB |
Output is correct |
13 |
Correct |
1 ms |
1388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
1 ms |
1536 KB |
Output is correct |
6 |
Correct |
1 ms |
1516 KB |
Output is correct |
7 |
Correct |
1 ms |
1388 KB |
Output is correct |
8 |
Correct |
1 ms |
1516 KB |
Output is correct |
9 |
Correct |
1 ms |
1516 KB |
Output is correct |
10 |
Correct |
1 ms |
1388 KB |
Output is correct |
11 |
Correct |
1 ms |
1532 KB |
Output is correct |
12 |
Correct |
1 ms |
1516 KB |
Output is correct |
13 |
Correct |
1 ms |
1388 KB |
Output is correct |
14 |
Correct |
9 ms |
7532 KB |
Output is correct |
15 |
Correct |
3 ms |
4972 KB |
Output is correct |
16 |
Correct |
5 ms |
4332 KB |
Output is correct |
17 |
Correct |
1 ms |
512 KB |
Output is correct |
18 |
Correct |
10 ms |
8044 KB |
Output is correct |
19 |
Correct |
9 ms |
7916 KB |
Output is correct |
20 |
Correct |
9 ms |
7936 KB |
Output is correct |
21 |
Correct |
10 ms |
8172 KB |
Output is correct |
22 |
Correct |
9 ms |
7916 KB |
Output is correct |
23 |
Correct |
9 ms |
7916 KB |
Output is correct |
24 |
Correct |
10 ms |
8044 KB |
Output is correct |
25 |
Correct |
9 ms |
7916 KB |
Output is correct |
26 |
Correct |
9 ms |
7916 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
1 ms |
1536 KB |
Output is correct |
6 |
Correct |
1 ms |
1516 KB |
Output is correct |
7 |
Correct |
1 ms |
1388 KB |
Output is correct |
8 |
Correct |
1 ms |
1516 KB |
Output is correct |
9 |
Correct |
1 ms |
1516 KB |
Output is correct |
10 |
Correct |
1 ms |
1388 KB |
Output is correct |
11 |
Correct |
1 ms |
1532 KB |
Output is correct |
12 |
Correct |
1 ms |
1516 KB |
Output is correct |
13 |
Correct |
1 ms |
1388 KB |
Output is correct |
14 |
Correct |
9 ms |
7532 KB |
Output is correct |
15 |
Correct |
3 ms |
4972 KB |
Output is correct |
16 |
Correct |
5 ms |
4332 KB |
Output is correct |
17 |
Correct |
1 ms |
512 KB |
Output is correct |
18 |
Correct |
10 ms |
8044 KB |
Output is correct |
19 |
Correct |
9 ms |
7916 KB |
Output is correct |
20 |
Correct |
9 ms |
7936 KB |
Output is correct |
21 |
Correct |
10 ms |
8172 KB |
Output is correct |
22 |
Correct |
9 ms |
7916 KB |
Output is correct |
23 |
Correct |
9 ms |
7916 KB |
Output is correct |
24 |
Correct |
10 ms |
8044 KB |
Output is correct |
25 |
Correct |
9 ms |
7916 KB |
Output is correct |
26 |
Correct |
9 ms |
7916 KB |
Output is correct |
27 |
Correct |
223 ms |
88172 KB |
Output is correct |
28 |
Correct |
17 ms |
26112 KB |
Output is correct |
29 |
Correct |
18 ms |
7916 KB |
Output is correct |
30 |
Correct |
1 ms |
620 KB |
Output is correct |
31 |
Correct |
168 ms |
72684 KB |
Output is correct |
32 |
Correct |
198 ms |
88556 KB |
Output is correct |
33 |
Correct |
208 ms |
88300 KB |
Output is correct |
34 |
Correct |
194 ms |
84140 KB |
Output is correct |
35 |
Correct |
211 ms |
88684 KB |
Output is correct |
36 |
Correct |
199 ms |
88300 KB |
Output is correct |
37 |
Correct |
240 ms |
88556 KB |
Output is correct |
38 |
Correct |
145 ms |
72556 KB |
Output is correct |
39 |
Correct |
155 ms |
72300 KB |
Output is correct |