#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
const int maxn = 3e3 + 2;
string a [maxn];
int64 row [maxn][maxn], col[maxn][maxn];
int main() {
int n,m;
cin >> n >> m;
for (int i = 1; i <= n; i++){
cin >> a[i];
a[i] = "#" + a[i];
for (int j = 1; j <= m; j++){
row[i][j] = row[i][j-1] + (a[i][j] == 'O');
}
}
for (int j = 1; j <= m; j++){
for (int i = 1; i <= n; i++){
col[j][i] = col[j][i-1] + (a[i][j] == 'I');
}
}
int64 rs = 0;
for (int i = 1; i <= n; i++){
for (int j = 1; j <= m; j++){
// cout << i << " " << j << " " << (row[i][n] - row[i][j]) << " " << (col[j][n] - col[j][i]) << "\n";
if (a[i][j] == 'J') rs+=(row[i][m] - row[i][j]) * (col[j][n] - col[j][i]);
}
}
cout << rs << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
400 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
1364 KB |
Output is correct |
6 |
Correct |
1 ms |
1236 KB |
Output is correct |
7 |
Correct |
1 ms |
1312 KB |
Output is correct |
8 |
Correct |
1 ms |
1344 KB |
Output is correct |
9 |
Correct |
1 ms |
1180 KB |
Output is correct |
10 |
Correct |
1 ms |
1236 KB |
Output is correct |
11 |
Correct |
1 ms |
1364 KB |
Output is correct |
12 |
Correct |
2 ms |
1236 KB |
Output is correct |
13 |
Correct |
1 ms |
1236 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
400 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
1364 KB |
Output is correct |
6 |
Correct |
1 ms |
1236 KB |
Output is correct |
7 |
Correct |
1 ms |
1312 KB |
Output is correct |
8 |
Correct |
1 ms |
1344 KB |
Output is correct |
9 |
Correct |
1 ms |
1180 KB |
Output is correct |
10 |
Correct |
1 ms |
1236 KB |
Output is correct |
11 |
Correct |
1 ms |
1364 KB |
Output is correct |
12 |
Correct |
2 ms |
1236 KB |
Output is correct |
13 |
Correct |
1 ms |
1236 KB |
Output is correct |
14 |
Correct |
11 ms |
7276 KB |
Output is correct |
15 |
Correct |
2 ms |
2132 KB |
Output is correct |
16 |
Correct |
7 ms |
5668 KB |
Output is correct |
17 |
Correct |
1 ms |
1620 KB |
Output is correct |
18 |
Correct |
13 ms |
8732 KB |
Output is correct |
19 |
Correct |
10 ms |
8532 KB |
Output is correct |
20 |
Correct |
11 ms |
8660 KB |
Output is correct |
21 |
Correct |
12 ms |
8784 KB |
Output is correct |
22 |
Correct |
12 ms |
8532 KB |
Output is correct |
23 |
Correct |
12 ms |
8720 KB |
Output is correct |
24 |
Correct |
13 ms |
8748 KB |
Output is correct |
25 |
Correct |
11 ms |
8532 KB |
Output is correct |
26 |
Correct |
12 ms |
8660 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
400 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
1364 KB |
Output is correct |
6 |
Correct |
1 ms |
1236 KB |
Output is correct |
7 |
Correct |
1 ms |
1312 KB |
Output is correct |
8 |
Correct |
1 ms |
1344 KB |
Output is correct |
9 |
Correct |
1 ms |
1180 KB |
Output is correct |
10 |
Correct |
1 ms |
1236 KB |
Output is correct |
11 |
Correct |
1 ms |
1364 KB |
Output is correct |
12 |
Correct |
2 ms |
1236 KB |
Output is correct |
13 |
Correct |
1 ms |
1236 KB |
Output is correct |
14 |
Correct |
11 ms |
7276 KB |
Output is correct |
15 |
Correct |
2 ms |
2132 KB |
Output is correct |
16 |
Correct |
7 ms |
5668 KB |
Output is correct |
17 |
Correct |
1 ms |
1620 KB |
Output is correct |
18 |
Correct |
13 ms |
8732 KB |
Output is correct |
19 |
Correct |
10 ms |
8532 KB |
Output is correct |
20 |
Correct |
11 ms |
8660 KB |
Output is correct |
21 |
Correct |
12 ms |
8784 KB |
Output is correct |
22 |
Correct |
12 ms |
8532 KB |
Output is correct |
23 |
Correct |
12 ms |
8720 KB |
Output is correct |
24 |
Correct |
13 ms |
8748 KB |
Output is correct |
25 |
Correct |
11 ms |
8532 KB |
Output is correct |
26 |
Correct |
12 ms |
8660 KB |
Output is correct |
27 |
Correct |
347 ms |
154148 KB |
Output is correct |
28 |
Correct |
7 ms |
10196 KB |
Output is correct |
29 |
Correct |
30 ms |
22912 KB |
Output is correct |
30 |
Correct |
6 ms |
10068 KB |
Output is correct |
31 |
Correct |
263 ms |
130120 KB |
Output is correct |
32 |
Correct |
337 ms |
158376 KB |
Output is correct |
33 |
Correct |
347 ms |
158764 KB |
Output is correct |
34 |
Correct |
296 ms |
141544 KB |
Output is correct |
35 |
Correct |
353 ms |
158396 KB |
Output is correct |
36 |
Correct |
357 ms |
158788 KB |
Output is correct |
37 |
Correct |
380 ms |
158992 KB |
Output is correct |
38 |
Correct |
237 ms |
129392 KB |
Output is correct |
39 |
Correct |
235 ms |
129836 KB |
Output is correct |