#include <iostream>
using namespace std;
#define ll long long
const int MAX = 3007;
char s[MAX][MAX];
int ingot[MAX][MAX];
int orb[MAX][MAX];
int main()
{
ios :: sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; ++i)
{
for (int j = 1; j <= m; ++j)
{
cin >> s[i][j];
ingot[i][j] = (s[i][j] == 'I');
orb[i][j] = (s[i][j] == 'O');
ingot[i][j] += ingot[i-1][j];
orb[i][j] += orb[i][j-1];
}
}
ll res = 0;
for (int i = 1; i <= n; ++i)
{
for (int j = 1; j <= m; ++j)
{
if (s[i][j] == 'J')
{
res += 1LL * (orb[i][m] - orb[i][j-1]) * (ingot[n][j] - ingot[i-1][j]);
}
}
}
cout << res << '\n';
return 0;
}
# |
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 |
2 ms |
1516 KB |
Output is correct |
6 |
Correct |
2 ms |
1516 KB |
Output is correct |
7 |
Correct |
2 ms |
1388 KB |
Output is correct |
8 |
Correct |
2 ms |
1516 KB |
Output is correct |
9 |
Correct |
2 ms |
1516 KB |
Output is correct |
10 |
Correct |
2 ms |
1388 KB |
Output is correct |
11 |
Correct |
2 ms |
1516 KB |
Output is correct |
12 |
Correct |
2 ms |
1516 KB |
Output is correct |
13 |
Correct |
2 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 |
2 ms |
1516 KB |
Output is correct |
6 |
Correct |
2 ms |
1516 KB |
Output is correct |
7 |
Correct |
2 ms |
1388 KB |
Output is correct |
8 |
Correct |
2 ms |
1516 KB |
Output is correct |
9 |
Correct |
2 ms |
1516 KB |
Output is correct |
10 |
Correct |
2 ms |
1388 KB |
Output is correct |
11 |
Correct |
2 ms |
1516 KB |
Output is correct |
12 |
Correct |
2 ms |
1516 KB |
Output is correct |
13 |
Correct |
2 ms |
1388 KB |
Output is correct |
14 |
Correct |
9 ms |
7532 KB |
Output is correct |
15 |
Correct |
4 ms |
4972 KB |
Output is correct |
16 |
Correct |
6 ms |
4332 KB |
Output is correct |
17 |
Correct |
1 ms |
492 KB |
Output is correct |
18 |
Correct |
11 ms |
8044 KB |
Output is correct |
19 |
Correct |
10 ms |
7916 KB |
Output is correct |
20 |
Correct |
11 ms |
7916 KB |
Output is correct |
21 |
Correct |
11 ms |
8044 KB |
Output is correct |
22 |
Correct |
10 ms |
7916 KB |
Output is correct |
23 |
Correct |
10 ms |
7916 KB |
Output is correct |
24 |
Correct |
11 ms |
8044 KB |
Output is correct |
25 |
Correct |
9 ms |
7916 KB |
Output is correct |
26 |
Correct |
10 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 |
2 ms |
1516 KB |
Output is correct |
6 |
Correct |
2 ms |
1516 KB |
Output is correct |
7 |
Correct |
2 ms |
1388 KB |
Output is correct |
8 |
Correct |
2 ms |
1516 KB |
Output is correct |
9 |
Correct |
2 ms |
1516 KB |
Output is correct |
10 |
Correct |
2 ms |
1388 KB |
Output is correct |
11 |
Correct |
2 ms |
1516 KB |
Output is correct |
12 |
Correct |
2 ms |
1516 KB |
Output is correct |
13 |
Correct |
2 ms |
1388 KB |
Output is correct |
14 |
Correct |
9 ms |
7532 KB |
Output is correct |
15 |
Correct |
4 ms |
4972 KB |
Output is correct |
16 |
Correct |
6 ms |
4332 KB |
Output is correct |
17 |
Correct |
1 ms |
492 KB |
Output is correct |
18 |
Correct |
11 ms |
8044 KB |
Output is correct |
19 |
Correct |
10 ms |
7916 KB |
Output is correct |
20 |
Correct |
11 ms |
7916 KB |
Output is correct |
21 |
Correct |
11 ms |
8044 KB |
Output is correct |
22 |
Correct |
10 ms |
7916 KB |
Output is correct |
23 |
Correct |
10 ms |
7916 KB |
Output is correct |
24 |
Correct |
11 ms |
8044 KB |
Output is correct |
25 |
Correct |
9 ms |
7916 KB |
Output is correct |
26 |
Correct |
10 ms |
7916 KB |
Output is correct |
27 |
Correct |
233 ms |
88172 KB |
Output is correct |
28 |
Correct |
17 ms |
26092 KB |
Output is correct |
29 |
Correct |
20 ms |
7788 KB |
Output is correct |
30 |
Correct |
2 ms |
620 KB |
Output is correct |
31 |
Correct |
169 ms |
72716 KB |
Output is correct |
32 |
Correct |
198 ms |
88684 KB |
Output is correct |
33 |
Correct |
196 ms |
88556 KB |
Output is correct |
34 |
Correct |
195 ms |
84396 KB |
Output is correct |
35 |
Correct |
203 ms |
88556 KB |
Output is correct |
36 |
Correct |
196 ms |
88300 KB |
Output is correct |
37 |
Correct |
239 ms |
88556 KB |
Output is correct |
38 |
Correct |
147 ms |
72684 KB |
Output is correct |
39 |
Correct |
143 ms |
72380 KB |
Output is correct |