#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define fi first
#define se second
using namespace std;
const int N = 3005;
int n, m;
char a[N][N];
ll ans = 0, dem[N];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
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--)
{
ll cnt = 0;
for(int j = m; j >= 1; j--)
{
if(a[i][j] == 'I')
dem[j]++;
if(a[i][j] == 'O')
cnt++;
if(a[i][j] == 'J')
ans += cnt * dem[j];
}
}
cout << ans;
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 |
0 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
604 KB |
Output is correct |
10 |
Correct |
0 ms |
608 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
736 KB |
Output is correct |
13 |
Correct |
0 ms |
728 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 |
0 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
604 KB |
Output is correct |
10 |
Correct |
0 ms |
608 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
736 KB |
Output is correct |
13 |
Correct |
0 ms |
728 KB |
Output is correct |
14 |
Correct |
4 ms |
1996 KB |
Output is correct |
15 |
Correct |
1 ms |
1632 KB |
Output is correct |
16 |
Correct |
2 ms |
1128 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
4 ms |
2020 KB |
Output is correct |
19 |
Correct |
3 ms |
2140 KB |
Output is correct |
20 |
Correct |
3 ms |
2140 KB |
Output is correct |
21 |
Correct |
4 ms |
2140 KB |
Output is correct |
22 |
Correct |
3 ms |
2140 KB |
Output is correct |
23 |
Correct |
3 ms |
2140 KB |
Output is correct |
24 |
Correct |
4 ms |
2140 KB |
Output is correct |
25 |
Correct |
3 ms |
2140 KB |
Output is correct |
26 |
Correct |
3 ms |
1960 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 |
0 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
604 KB |
Output is correct |
10 |
Correct |
0 ms |
608 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
736 KB |
Output is correct |
13 |
Correct |
0 ms |
728 KB |
Output is correct |
14 |
Correct |
4 ms |
1996 KB |
Output is correct |
15 |
Correct |
1 ms |
1632 KB |
Output is correct |
16 |
Correct |
2 ms |
1128 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
4 ms |
2020 KB |
Output is correct |
19 |
Correct |
3 ms |
2140 KB |
Output is correct |
20 |
Correct |
3 ms |
2140 KB |
Output is correct |
21 |
Correct |
4 ms |
2140 KB |
Output is correct |
22 |
Correct |
3 ms |
2140 KB |
Output is correct |
23 |
Correct |
3 ms |
2140 KB |
Output is correct |
24 |
Correct |
4 ms |
2140 KB |
Output is correct |
25 |
Correct |
3 ms |
2140 KB |
Output is correct |
26 |
Correct |
3 ms |
1960 KB |
Output is correct |
27 |
Correct |
128 ms |
17592 KB |
Output is correct |
28 |
Correct |
3 ms |
7256 KB |
Output is correct |
29 |
Correct |
6 ms |
1880 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
88 ms |
13908 KB |
Output is correct |
32 |
Correct |
86 ms |
17872 KB |
Output is correct |
33 |
Correct |
83 ms |
18100 KB |
Output is correct |
34 |
Correct |
96 ms |
16068 KB |
Output is correct |
35 |
Correct |
84 ms |
18004 KB |
Output is correct |
36 |
Correct |
117 ms |
18004 KB |
Output is correct |
37 |
Correct |
141 ms |
18164 KB |
Output is correct |
38 |
Correct |
80 ms |
13648 KB |
Output is correct |
39 |
Correct |
57 ms |
13652 KB |
Output is correct |