#include<bits/stdc++.h>
using namespace std;
const int N = 3e3 + 5;
int satir[N][N], sutun[N][N];
char grid[N][N];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// #ifndef ONLINE_JUDGE
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
// #endif
int n, m;
cin >> n >> m;
for(int i = 0; i < n; i++)
{
for(int j = 0; j < m; j++)
{
cin >> grid[i][j];
}
}
for(int j = m - 1; j >= 0; j--)
{
for(int i = n - 1; i >= 0; i--)
{
sutun[i][j] = sutun[i + 1][j];
if(grid[i][j] == 'I')
sutun[i][j]++;
}
}
for(int i = n - 1; i >= 0; i--)
{
for(int j = m - 1; j >= 0; j--)
{
satir[i][j] = satir[i][j + 1];
if(grid[i][j] == 'O')
satir[i][j]++;
}
}
long long cevap = 0;
for(int i = 0; i < n; i++)
{
for(int j = 0; j < m; j++)
{
if(grid[i][j] == 'J')
{
cevap += satir[i][j] * sutun[i][j];
}
}
}
cout << cevap << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
324 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
1484 KB |
Output is correct |
6 |
Correct |
2 ms |
1484 KB |
Output is correct |
7 |
Correct |
1 ms |
1356 KB |
Output is correct |
8 |
Correct |
1 ms |
1488 KB |
Output is correct |
9 |
Correct |
1 ms |
1484 KB |
Output is correct |
10 |
Correct |
1 ms |
1356 KB |
Output is correct |
11 |
Correct |
1 ms |
1484 KB |
Output is correct |
12 |
Correct |
1 ms |
1484 KB |
Output is correct |
13 |
Correct |
1 ms |
1352 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
324 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
1484 KB |
Output is correct |
6 |
Correct |
2 ms |
1484 KB |
Output is correct |
7 |
Correct |
1 ms |
1356 KB |
Output is correct |
8 |
Correct |
1 ms |
1488 KB |
Output is correct |
9 |
Correct |
1 ms |
1484 KB |
Output is correct |
10 |
Correct |
1 ms |
1356 KB |
Output is correct |
11 |
Correct |
1 ms |
1484 KB |
Output is correct |
12 |
Correct |
1 ms |
1484 KB |
Output is correct |
13 |
Correct |
1 ms |
1352 KB |
Output is correct |
14 |
Correct |
9 ms |
7500 KB |
Output is correct |
15 |
Correct |
2 ms |
4940 KB |
Output is correct |
16 |
Correct |
4 ms |
4300 KB |
Output is correct |
17 |
Correct |
1 ms |
460 KB |
Output is correct |
18 |
Correct |
10 ms |
8012 KB |
Output is correct |
19 |
Correct |
9 ms |
7884 KB |
Output is correct |
20 |
Correct |
9 ms |
7756 KB |
Output is correct |
21 |
Correct |
9 ms |
8012 KB |
Output is correct |
22 |
Correct |
8 ms |
7884 KB |
Output is correct |
23 |
Correct |
11 ms |
7756 KB |
Output is correct |
24 |
Correct |
13 ms |
8012 KB |
Output is correct |
25 |
Correct |
8 ms |
7884 KB |
Output is correct |
26 |
Correct |
9 ms |
7756 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
324 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
1484 KB |
Output is correct |
6 |
Correct |
2 ms |
1484 KB |
Output is correct |
7 |
Correct |
1 ms |
1356 KB |
Output is correct |
8 |
Correct |
1 ms |
1488 KB |
Output is correct |
9 |
Correct |
1 ms |
1484 KB |
Output is correct |
10 |
Correct |
1 ms |
1356 KB |
Output is correct |
11 |
Correct |
1 ms |
1484 KB |
Output is correct |
12 |
Correct |
1 ms |
1484 KB |
Output is correct |
13 |
Correct |
1 ms |
1352 KB |
Output is correct |
14 |
Correct |
9 ms |
7500 KB |
Output is correct |
15 |
Correct |
2 ms |
4940 KB |
Output is correct |
16 |
Correct |
4 ms |
4300 KB |
Output is correct |
17 |
Correct |
1 ms |
460 KB |
Output is correct |
18 |
Correct |
10 ms |
8012 KB |
Output is correct |
19 |
Correct |
9 ms |
7884 KB |
Output is correct |
20 |
Correct |
9 ms |
7756 KB |
Output is correct |
21 |
Correct |
9 ms |
8012 KB |
Output is correct |
22 |
Correct |
8 ms |
7884 KB |
Output is correct |
23 |
Correct |
11 ms |
7756 KB |
Output is correct |
24 |
Correct |
13 ms |
8012 KB |
Output is correct |
25 |
Correct |
8 ms |
7884 KB |
Output is correct |
26 |
Correct |
9 ms |
7756 KB |
Output is correct |
27 |
Correct |
317 ms |
87936 KB |
Output is correct |
28 |
Correct |
13 ms |
25996 KB |
Output is correct |
29 |
Correct |
15 ms |
7756 KB |
Output is correct |
30 |
Correct |
1 ms |
588 KB |
Output is correct |
31 |
Correct |
244 ms |
72484 KB |
Output is correct |
32 |
Correct |
294 ms |
88348 KB |
Output is correct |
33 |
Correct |
294 ms |
88120 KB |
Output is correct |
34 |
Correct |
275 ms |
84024 KB |
Output is correct |
35 |
Correct |
285 ms |
88384 KB |
Output is correct |
36 |
Correct |
277 ms |
88128 KB |
Output is correct |
37 |
Correct |
333 ms |
88516 KB |
Output is correct |
38 |
Correct |
196 ms |
72624 KB |
Output is correct |
39 |
Correct |
201 ms |
72236 KB |
Output is correct |