#include <bits/stdc++.h>
using namespace std;
const int MxN = 3005;
int n , m , d[MxN][MxN] , r[MxN][MxN] , ans;
char grid[MxN][MxN];
int main()
{
cin >> n >> m;
for(int i=1 ; i<=n ; i++)for(int j=1 ; j<=m ; j++)cin >> grid[i][j];
for(int i=n ; i>=1 ; i--)for(int j=1 ; j<=m ; j++)d[i][j] = d[i+1][j] + (grid[i][j]=='I');
for(int i=1 ; i<=n ; i++)for(int j=m ; j>=1 ; j--)r[i][j] = r[i][j+1] + (grid[i][j]=='O');
for(int i=1 ; i<=n ; i++)for(int j=1 ; j<=m ; j++)if(grid[i][j]=='J')ans+=d[i][j]*r[i][j];
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
2 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1492 KB |
Output is correct |
7 |
Correct |
2 ms |
1364 KB |
Output is correct |
8 |
Correct |
2 ms |
1472 KB |
Output is correct |
9 |
Correct |
2 ms |
1492 KB |
Output is correct |
10 |
Correct |
2 ms |
1364 KB |
Output is correct |
11 |
Correct |
2 ms |
1492 KB |
Output is correct |
12 |
Correct |
2 ms |
1492 KB |
Output is correct |
13 |
Correct |
2 ms |
1340 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 |
2 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1492 KB |
Output is correct |
7 |
Correct |
2 ms |
1364 KB |
Output is correct |
8 |
Correct |
2 ms |
1472 KB |
Output is correct |
9 |
Correct |
2 ms |
1492 KB |
Output is correct |
10 |
Correct |
2 ms |
1364 KB |
Output is correct |
11 |
Correct |
2 ms |
1492 KB |
Output is correct |
12 |
Correct |
2 ms |
1492 KB |
Output is correct |
13 |
Correct |
2 ms |
1340 KB |
Output is correct |
14 |
Correct |
15 ms |
7416 KB |
Output is correct |
15 |
Correct |
3 ms |
4948 KB |
Output is correct |
16 |
Correct |
10 ms |
4264 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
19 ms |
8004 KB |
Output is correct |
19 |
Correct |
21 ms |
7900 KB |
Output is correct |
20 |
Incorrect |
19 ms |
7732 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
2 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1492 KB |
Output is correct |
7 |
Correct |
2 ms |
1364 KB |
Output is correct |
8 |
Correct |
2 ms |
1472 KB |
Output is correct |
9 |
Correct |
2 ms |
1492 KB |
Output is correct |
10 |
Correct |
2 ms |
1364 KB |
Output is correct |
11 |
Correct |
2 ms |
1492 KB |
Output is correct |
12 |
Correct |
2 ms |
1492 KB |
Output is correct |
13 |
Correct |
2 ms |
1340 KB |
Output is correct |
14 |
Correct |
15 ms |
7416 KB |
Output is correct |
15 |
Correct |
3 ms |
4948 KB |
Output is correct |
16 |
Correct |
10 ms |
4264 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
19 ms |
8004 KB |
Output is correct |
19 |
Correct |
21 ms |
7900 KB |
Output is correct |
20 |
Incorrect |
19 ms |
7732 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |