#include <iostream>
using namespace std;
using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
int const nmax = 3000;
char v[1 + nmax][1 + nmax];
int ingots[1 + nmax][1 + nmax], orbs[1 + nmax][1 + nmax];
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 >> v[i][j];
if(v[i][j] == 'O')
orbs[i][j]++;
else if(v[i][j] == 'I')
ingots[i][j]++;
}
for(int i = n; 1 <= i; i--)
for(int j = m; 1 <= j; j--) {
orbs[i][j] += orbs[i][j + 1];
ingots[i][j] += ingots[i + 1][j];
}
ll result = 0;
for(int i = 1;i <= n; i++)
for(int j = 1;j <= m; j++)
if(v[i][j] == 'J') {
result += orbs[i][j] * ingots[i][j];
}
cout << result << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
1528 KB |
Output is correct |
6 |
Correct |
3 ms |
1528 KB |
Output is correct |
7 |
Correct |
3 ms |
1400 KB |
Output is correct |
8 |
Correct |
3 ms |
1528 KB |
Output is correct |
9 |
Correct |
3 ms |
1528 KB |
Output is correct |
10 |
Correct |
3 ms |
1404 KB |
Output is correct |
11 |
Correct |
3 ms |
1528 KB |
Output is correct |
12 |
Correct |
6 ms |
1528 KB |
Output is correct |
13 |
Correct |
3 ms |
1400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
1528 KB |
Output is correct |
6 |
Correct |
3 ms |
1528 KB |
Output is correct |
7 |
Correct |
3 ms |
1400 KB |
Output is correct |
8 |
Correct |
3 ms |
1528 KB |
Output is correct |
9 |
Correct |
3 ms |
1528 KB |
Output is correct |
10 |
Correct |
3 ms |
1404 KB |
Output is correct |
11 |
Correct |
3 ms |
1528 KB |
Output is correct |
12 |
Correct |
6 ms |
1528 KB |
Output is correct |
13 |
Correct |
3 ms |
1400 KB |
Output is correct |
14 |
Correct |
14 ms |
7288 KB |
Output is correct |
15 |
Correct |
6 ms |
5092 KB |
Output is correct |
16 |
Correct |
8 ms |
4216 KB |
Output is correct |
17 |
Correct |
2 ms |
504 KB |
Output is correct |
18 |
Correct |
17 ms |
7800 KB |
Output is correct |
19 |
Correct |
13 ms |
7672 KB |
Output is correct |
20 |
Correct |
13 ms |
7672 KB |
Output is correct |
21 |
Correct |
17 ms |
7800 KB |
Output is correct |
22 |
Correct |
13 ms |
7672 KB |
Output is correct |
23 |
Correct |
13 ms |
7544 KB |
Output is correct |
24 |
Correct |
16 ms |
7800 KB |
Output is correct |
25 |
Correct |
13 ms |
7672 KB |
Output is correct |
26 |
Correct |
13 ms |
7720 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
1528 KB |
Output is correct |
6 |
Correct |
3 ms |
1528 KB |
Output is correct |
7 |
Correct |
3 ms |
1400 KB |
Output is correct |
8 |
Correct |
3 ms |
1528 KB |
Output is correct |
9 |
Correct |
3 ms |
1528 KB |
Output is correct |
10 |
Correct |
3 ms |
1404 KB |
Output is correct |
11 |
Correct |
3 ms |
1528 KB |
Output is correct |
12 |
Correct |
6 ms |
1528 KB |
Output is correct |
13 |
Correct |
3 ms |
1400 KB |
Output is correct |
14 |
Correct |
14 ms |
7288 KB |
Output is correct |
15 |
Correct |
6 ms |
5092 KB |
Output is correct |
16 |
Correct |
8 ms |
4216 KB |
Output is correct |
17 |
Correct |
2 ms |
504 KB |
Output is correct |
18 |
Correct |
17 ms |
7800 KB |
Output is correct |
19 |
Correct |
13 ms |
7672 KB |
Output is correct |
20 |
Correct |
13 ms |
7672 KB |
Output is correct |
21 |
Correct |
17 ms |
7800 KB |
Output is correct |
22 |
Correct |
13 ms |
7672 KB |
Output is correct |
23 |
Correct |
13 ms |
7544 KB |
Output is correct |
24 |
Correct |
16 ms |
7800 KB |
Output is correct |
25 |
Correct |
13 ms |
7672 KB |
Output is correct |
26 |
Correct |
13 ms |
7720 KB |
Output is correct |
27 |
Incorrect |
360 ms |
79780 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |