// Src : Vux2Code
#include <bits/stdc++.h>
#define pq_rvs pll,vector<pll>,greater<pll>
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pll;
const ll maxN = 3e3 + 5, inf64 = 1e18, mod = 1e9 + 7, maxLog = 20;
ll t = 1;
ll n, m, Iunder [maxN] [maxN], Oright [maxN] [maxN], ans;
char a [maxN] [maxN];
void solve () {
cin >> n >> m;
for (int i = 1; i <= n; i ++) for (int j = 1; j <= m; j ++) cin >> a [i] [j];
for (int i = n; i >= 1; i --) for (int j = m; j >= 1; j --) {
Iunder [i] [j] = Iunder [i + 1] [j] + (a [i] [j] == 'I');
Oright [i] [j] = Oright [i] [j + 1] + (a [i] [j] == 'O');
ans += (a [i] [j] == 'J') * Iunder [i] [j] * Oright [i] [j];
}
cout << ans;
}
int main (){
ios::sync_with_stdio (0);
cin. tie (0);
cout. tie (0);
//freopen (".inp", "r", stdin);
//freopen (".out", "w", stdout);
//cin >> t;
while (t --) solve ();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
1628 KB |
Output is correct |
6 |
Correct |
1 ms |
1624 KB |
Output is correct |
7 |
Correct |
1 ms |
1372 KB |
Output is correct |
8 |
Correct |
1 ms |
1628 KB |
Output is correct |
9 |
Correct |
1 ms |
1488 KB |
Output is correct |
10 |
Correct |
1 ms |
1372 KB |
Output is correct |
11 |
Correct |
2 ms |
1628 KB |
Output is correct |
12 |
Correct |
1 ms |
1628 KB |
Output is correct |
13 |
Correct |
1 ms |
1372 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
1628 KB |
Output is correct |
6 |
Correct |
1 ms |
1624 KB |
Output is correct |
7 |
Correct |
1 ms |
1372 KB |
Output is correct |
8 |
Correct |
1 ms |
1628 KB |
Output is correct |
9 |
Correct |
1 ms |
1488 KB |
Output is correct |
10 |
Correct |
1 ms |
1372 KB |
Output is correct |
11 |
Correct |
2 ms |
1628 KB |
Output is correct |
12 |
Correct |
1 ms |
1628 KB |
Output is correct |
13 |
Correct |
1 ms |
1372 KB |
Output is correct |
14 |
Correct |
6 ms |
9052 KB |
Output is correct |
15 |
Correct |
2 ms |
5020 KB |
Output is correct |
16 |
Correct |
3 ms |
5468 KB |
Output is correct |
17 |
Correct |
0 ms |
604 KB |
Output is correct |
18 |
Correct |
6 ms |
10072 KB |
Output is correct |
19 |
Correct |
6 ms |
9820 KB |
Output is correct |
20 |
Correct |
6 ms |
9912 KB |
Output is correct |
21 |
Correct |
6 ms |
10076 KB |
Output is correct |
22 |
Correct |
6 ms |
9816 KB |
Output is correct |
23 |
Correct |
6 ms |
9820 KB |
Output is correct |
24 |
Correct |
7 ms |
10076 KB |
Output is correct |
25 |
Correct |
6 ms |
9828 KB |
Output is correct |
26 |
Correct |
7 ms |
9820 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
1628 KB |
Output is correct |
6 |
Correct |
1 ms |
1624 KB |
Output is correct |
7 |
Correct |
1 ms |
1372 KB |
Output is correct |
8 |
Correct |
1 ms |
1628 KB |
Output is correct |
9 |
Correct |
1 ms |
1488 KB |
Output is correct |
10 |
Correct |
1 ms |
1372 KB |
Output is correct |
11 |
Correct |
2 ms |
1628 KB |
Output is correct |
12 |
Correct |
1 ms |
1628 KB |
Output is correct |
13 |
Correct |
1 ms |
1372 KB |
Output is correct |
14 |
Correct |
6 ms |
9052 KB |
Output is correct |
15 |
Correct |
2 ms |
5020 KB |
Output is correct |
16 |
Correct |
3 ms |
5468 KB |
Output is correct |
17 |
Correct |
0 ms |
604 KB |
Output is correct |
18 |
Correct |
6 ms |
10072 KB |
Output is correct |
19 |
Correct |
6 ms |
9820 KB |
Output is correct |
20 |
Correct |
6 ms |
9912 KB |
Output is correct |
21 |
Correct |
6 ms |
10076 KB |
Output is correct |
22 |
Correct |
6 ms |
9816 KB |
Output is correct |
23 |
Correct |
6 ms |
9820 KB |
Output is correct |
24 |
Correct |
7 ms |
10076 KB |
Output is correct |
25 |
Correct |
6 ms |
9828 KB |
Output is correct |
26 |
Correct |
7 ms |
9820 KB |
Output is correct |
27 |
Correct |
145 ms |
158548 KB |
Output is correct |
28 |
Correct |
10 ms |
26456 KB |
Output is correct |
29 |
Correct |
11 ms |
14024 KB |
Output is correct |
30 |
Correct |
1 ms |
860 KB |
Output is correct |
31 |
Correct |
110 ms |
131532 KB |
Output is correct |
32 |
Correct |
145 ms |
159060 KB |
Output is correct |
33 |
Correct |
148 ms |
158548 KB |
Output is correct |
34 |
Correct |
137 ms |
152388 KB |
Output is correct |
35 |
Correct |
148 ms |
159060 KB |
Output is correct |
36 |
Correct |
148 ms |
158616 KB |
Output is correct |
37 |
Correct |
147 ms |
159056 KB |
Output is correct |
38 |
Correct |
106 ms |
130896 KB |
Output is correct |
39 |
Correct |
114 ms |
130896 KB |
Output is correct |