#include <iostream>
#define ll long long
using namespace std;
int H, W;
string A[3001];
int hor[3001][3001], ver[3001][3001];
int main()
{
ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> H >> W;
for (int i = 0; i < H; i++) cin >> A[i];
for (int i = 0; i < H; i++)
{
for (int j = W - 1; j >= 0; j--)
{
hor[i][j] = (A[i][j] == 'O');
if (j + 1 < W) hor[i][j] += hor[i][j + 1];
}
}
for (int i = H - 1; i >= 0; i--)
{
for (int j = 0; j < W; j++)
{
ver[i][j] = (A[i][j] == 'I');
if (i + 1 < H) ver[i][j] += ver[i + 1][j];
}
}
ll res = 0;
for (int i = 0; i < H; i++)
{
for (int j = 0; j < W; j++)
{
res += 1ll * (A[i][j] == 'J') * hor[i][j] * ver[i][j];
}
}
cout << res << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
416 KB |
Output is correct |
3 |
Correct |
1 ms |
420 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
1 ms |
1228 KB |
Output is correct |
6 |
Correct |
1 ms |
1228 KB |
Output is correct |
7 |
Correct |
1 ms |
1100 KB |
Output is correct |
8 |
Correct |
1 ms |
1228 KB |
Output is correct |
9 |
Correct |
1 ms |
1228 KB |
Output is correct |
10 |
Correct |
1 ms |
1100 KB |
Output is correct |
11 |
Correct |
1 ms |
1228 KB |
Output is correct |
12 |
Correct |
1 ms |
1228 KB |
Output is correct |
13 |
Correct |
1 ms |
1100 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
416 KB |
Output is correct |
3 |
Correct |
1 ms |
420 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
1 ms |
1228 KB |
Output is correct |
6 |
Correct |
1 ms |
1228 KB |
Output is correct |
7 |
Correct |
1 ms |
1100 KB |
Output is correct |
8 |
Correct |
1 ms |
1228 KB |
Output is correct |
9 |
Correct |
1 ms |
1228 KB |
Output is correct |
10 |
Correct |
1 ms |
1100 KB |
Output is correct |
11 |
Correct |
1 ms |
1228 KB |
Output is correct |
12 |
Correct |
1 ms |
1228 KB |
Output is correct |
13 |
Correct |
1 ms |
1100 KB |
Output is correct |
14 |
Correct |
5 ms |
6312 KB |
Output is correct |
15 |
Correct |
2 ms |
3788 KB |
Output is correct |
16 |
Correct |
3 ms |
3788 KB |
Output is correct |
17 |
Correct |
1 ms |
460 KB |
Output is correct |
18 |
Correct |
6 ms |
6860 KB |
Output is correct |
19 |
Correct |
6 ms |
6732 KB |
Output is correct |
20 |
Correct |
6 ms |
6700 KB |
Output is correct |
21 |
Correct |
6 ms |
6828 KB |
Output is correct |
22 |
Correct |
6 ms |
6732 KB |
Output is correct |
23 |
Correct |
6 ms |
6732 KB |
Output is correct |
24 |
Correct |
6 ms |
6860 KB |
Output is correct |
25 |
Correct |
6 ms |
6732 KB |
Output is correct |
26 |
Correct |
6 ms |
6764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
416 KB |
Output is correct |
3 |
Correct |
1 ms |
420 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
1 ms |
1228 KB |
Output is correct |
6 |
Correct |
1 ms |
1228 KB |
Output is correct |
7 |
Correct |
1 ms |
1100 KB |
Output is correct |
8 |
Correct |
1 ms |
1228 KB |
Output is correct |
9 |
Correct |
1 ms |
1228 KB |
Output is correct |
10 |
Correct |
1 ms |
1100 KB |
Output is correct |
11 |
Correct |
1 ms |
1228 KB |
Output is correct |
12 |
Correct |
1 ms |
1228 KB |
Output is correct |
13 |
Correct |
1 ms |
1100 KB |
Output is correct |
14 |
Correct |
5 ms |
6312 KB |
Output is correct |
15 |
Correct |
2 ms |
3788 KB |
Output is correct |
16 |
Correct |
3 ms |
3788 KB |
Output is correct |
17 |
Correct |
1 ms |
460 KB |
Output is correct |
18 |
Correct |
6 ms |
6860 KB |
Output is correct |
19 |
Correct |
6 ms |
6732 KB |
Output is correct |
20 |
Correct |
6 ms |
6700 KB |
Output is correct |
21 |
Correct |
6 ms |
6828 KB |
Output is correct |
22 |
Correct |
6 ms |
6732 KB |
Output is correct |
23 |
Correct |
6 ms |
6732 KB |
Output is correct |
24 |
Correct |
6 ms |
6860 KB |
Output is correct |
25 |
Correct |
6 ms |
6732 KB |
Output is correct |
26 |
Correct |
6 ms |
6764 KB |
Output is correct |
27 |
Correct |
115 ms |
88304 KB |
Output is correct |
28 |
Correct |
12 ms |
19240 KB |
Output is correct |
29 |
Correct |
9 ms |
7840 KB |
Output is correct |
30 |
Correct |
1 ms |
588 KB |
Output is correct |
31 |
Correct |
82 ms |
71832 KB |
Output is correct |
32 |
Correct |
105 ms |
89116 KB |
Output is correct |
33 |
Correct |
102 ms |
89028 KB |
Output is correct |
34 |
Correct |
88 ms |
83192 KB |
Output is correct |
35 |
Correct |
110 ms |
89348 KB |
Output is correct |
36 |
Correct |
99 ms |
89016 KB |
Output is correct |
37 |
Correct |
101 ms |
89284 KB |
Output is correct |
38 |
Correct |
76 ms |
71688 KB |
Output is correct |
39 |
Correct |
75 ms |
71492 KB |
Output is correct |