#include<bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define int long long
#define N 200005
#define pii pair<int, int>
#define piii pair<int, pii>
using namespace std;
int n, m, i, j, d[3003][3003], r[3003][3003], ans;
char a[3003][3003];
main()
{
std::ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for(i = 0; i < n; i++)
for(j = 0; j < m; j++)
cin >> a[i][j];
for(i = n - 1; i >= 0; i--)
for(j = m - 1; j >= 0; j--)
{
if(j == m - 1) r[i][j] = 0;
else if(a[i][j + 1] == 'O') r[i][j] = r[i][j + 1] + 1;
else r[i][j] = r[i][j + 1];
if(i == n - 1) d[i][j] = 0;
else if(a[i + 1][j] == 'I') d[i][j] = d[i + 1][j] + 1;
else d[i][j] = d[i + 1][j];
if(a[i][j] == 'J') ans += r[i][j] * d[i][j];
}
cout << ans << '\n';
}
Compilation message
joi2019_ho_t1.cpp:14:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
14 | main()
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
2 ms |
1492 KB |
Output is correct |
7 |
Correct |
1 ms |
1364 KB |
Output is correct |
8 |
Correct |
1 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
2 ms |
1492 KB |
Output is correct |
7 |
Correct |
1 ms |
1364 KB |
Output is correct |
8 |
Correct |
1 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
14 |
Correct |
7 ms |
8948 KB |
Output is correct |
15 |
Correct |
2 ms |
4948 KB |
Output is correct |
16 |
Correct |
4 ms |
5224 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
8 ms |
9940 KB |
Output is correct |
19 |
Correct |
7 ms |
9812 KB |
Output is correct |
20 |
Correct |
7 ms |
9768 KB |
Output is correct |
21 |
Correct |
9 ms |
9904 KB |
Output is correct |
22 |
Correct |
7 ms |
9812 KB |
Output is correct |
23 |
Correct |
7 ms |
9684 KB |
Output is correct |
24 |
Correct |
7 ms |
9940 KB |
Output is correct |
25 |
Correct |
7 ms |
9696 KB |
Output is correct |
26 |
Correct |
7 ms |
9696 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
2 ms |
1492 KB |
Output is correct |
7 |
Correct |
1 ms |
1364 KB |
Output is correct |
8 |
Correct |
1 ms |
1492 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
1492 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
14 |
Correct |
7 ms |
8948 KB |
Output is correct |
15 |
Correct |
2 ms |
4948 KB |
Output is correct |
16 |
Correct |
4 ms |
5224 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
8 ms |
9940 KB |
Output is correct |
19 |
Correct |
7 ms |
9812 KB |
Output is correct |
20 |
Correct |
7 ms |
9768 KB |
Output is correct |
21 |
Correct |
9 ms |
9904 KB |
Output is correct |
22 |
Correct |
7 ms |
9812 KB |
Output is correct |
23 |
Correct |
7 ms |
9684 KB |
Output is correct |
24 |
Correct |
7 ms |
9940 KB |
Output is correct |
25 |
Correct |
7 ms |
9696 KB |
Output is correct |
26 |
Correct |
7 ms |
9696 KB |
Output is correct |
27 |
Correct |
201 ms |
158448 KB |
Output is correct |
28 |
Correct |
11 ms |
26324 KB |
Output is correct |
29 |
Correct |
13 ms |
13888 KB |
Output is correct |
30 |
Correct |
1 ms |
740 KB |
Output is correct |
31 |
Correct |
140 ms |
131364 KB |
Output is correct |
32 |
Correct |
158 ms |
158828 KB |
Output is correct |
33 |
Correct |
146 ms |
158344 KB |
Output is correct |
34 |
Correct |
158 ms |
152236 KB |
Output is correct |
35 |
Correct |
153 ms |
159000 KB |
Output is correct |
36 |
Correct |
148 ms |
158412 KB |
Output is correct |
37 |
Correct |
188 ms |
158924 KB |
Output is correct |
38 |
Correct |
116 ms |
130764 KB |
Output is correct |
39 |
Correct |
122 ms |
130680 KB |
Output is correct |