#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
#define f first
#define s second
#define LOGN 21
const ll MOD = 1e9 + 7;
const ll MAXN = 3000 + 100;
vector<string> grid;
int toR[MAXN][MAXN], toD[MAXN][MAXN];
int main() {
fast;
int H, W;
cin >> H >> W;
grid = vector<string>(H+1);
for (int i = 1; i <= H; i++) {
cin >> grid[i];
grid[i] = "#" + grid[i];
}
for (int i = 1; i <= H; i++) {
for (int j = W; j >= 1; j--)
toR[i][j] = toR[i][j+1] + (grid[i][j] == 'O');
}
for (int i = 1; i <= W; i++) {
for (int j = H; j >= 1; j--)
toD[j][i] = toD[j+1][i] + (grid[j][i] == 'I');
}
int ans = 0;
for (int i = 1; i <= H; i++) {
for (int j = 1; j <= W; j++) {
if (grid[i][j] == 'J')
ans += toR[i][j] * toD[i][j];
}
}
cout << ans << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
604 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 |
1372 KB |
Output is correct |
6 |
Correct |
1 ms |
1116 KB |
Output is correct |
7 |
Correct |
1 ms |
1116 KB |
Output is correct |
8 |
Correct |
1 ms |
1372 KB |
Output is correct |
9 |
Correct |
1 ms |
1116 KB |
Output is correct |
10 |
Correct |
1 ms |
1112 KB |
Output is correct |
11 |
Correct |
1 ms |
1372 KB |
Output is correct |
12 |
Correct |
1 ms |
1116 KB |
Output is correct |
13 |
Correct |
1 ms |
1116 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
604 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 |
1372 KB |
Output is correct |
6 |
Correct |
1 ms |
1116 KB |
Output is correct |
7 |
Correct |
1 ms |
1116 KB |
Output is correct |
8 |
Correct |
1 ms |
1372 KB |
Output is correct |
9 |
Correct |
1 ms |
1116 KB |
Output is correct |
10 |
Correct |
1 ms |
1112 KB |
Output is correct |
11 |
Correct |
1 ms |
1372 KB |
Output is correct |
12 |
Correct |
1 ms |
1116 KB |
Output is correct |
13 |
Correct |
1 ms |
1116 KB |
Output is correct |
14 |
Correct |
5 ms |
6236 KB |
Output is correct |
15 |
Correct |
2 ms |
3676 KB |
Output is correct |
16 |
Correct |
3 ms |
3676 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
6 ms |
6752 KB |
Output is correct |
19 |
Correct |
5 ms |
6748 KB |
Output is correct |
20 |
Incorrect |
5 ms |
6620 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
604 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 |
1372 KB |
Output is correct |
6 |
Correct |
1 ms |
1116 KB |
Output is correct |
7 |
Correct |
1 ms |
1116 KB |
Output is correct |
8 |
Correct |
1 ms |
1372 KB |
Output is correct |
9 |
Correct |
1 ms |
1116 KB |
Output is correct |
10 |
Correct |
1 ms |
1112 KB |
Output is correct |
11 |
Correct |
1 ms |
1372 KB |
Output is correct |
12 |
Correct |
1 ms |
1116 KB |
Output is correct |
13 |
Correct |
1 ms |
1116 KB |
Output is correct |
14 |
Correct |
5 ms |
6236 KB |
Output is correct |
15 |
Correct |
2 ms |
3676 KB |
Output is correct |
16 |
Correct |
3 ms |
3676 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
6 ms |
6752 KB |
Output is correct |
19 |
Correct |
5 ms |
6748 KB |
Output is correct |
20 |
Incorrect |
5 ms |
6620 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |