#include <bits/stdc++.h>
#define pb push_back
#define int ll
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
int N = 3e3 + 1;
signed main()
{
int h, w; cin >> h >> w;
vii a(N, vi(N)), b(N, vi(N));
vpii J(N);
vector<vector<char>> gr(N, vector<char>(N));
for (int i = 1; i <= h; i++)
{
string s; cin >> s;
s = "$" + s;
for (int j = 1; j <= w; j++)
{
gr[i][j] = s[j];
if (s[j] == 'J') J.pb({i, j});
}
}
for (int i = h; i >= 1; i--)
{
for (int j = w; j >= 1; j--)
{
a[i][j] = a[i][j + 1] + (gr[i][j] == 'O');
b[i][j] = b[i + 1][j] + (gr[i][j] == 'I');
}
}
int ans = 0;
for (auto [i, j] : J)
{
ans += a[i][j] * b[i][j];
}
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
68 ms |
150504 KB |
Output is correct |
2 |
Correct |
67 ms |
150436 KB |
Output is correct |
3 |
Correct |
73 ms |
150400 KB |
Output is correct |
4 |
Correct |
68 ms |
150608 KB |
Output is correct |
5 |
Correct |
68 ms |
150568 KB |
Output is correct |
6 |
Correct |
68 ms |
150608 KB |
Output is correct |
7 |
Correct |
65 ms |
150612 KB |
Output is correct |
8 |
Correct |
66 ms |
150800 KB |
Output is correct |
9 |
Correct |
70 ms |
150596 KB |
Output is correct |
10 |
Correct |
78 ms |
150556 KB |
Output is correct |
11 |
Correct |
73 ms |
150764 KB |
Output is correct |
12 |
Correct |
67 ms |
150608 KB |
Output is correct |
13 |
Correct |
71 ms |
150868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
68 ms |
150504 KB |
Output is correct |
2 |
Correct |
67 ms |
150436 KB |
Output is correct |
3 |
Correct |
73 ms |
150400 KB |
Output is correct |
4 |
Correct |
68 ms |
150608 KB |
Output is correct |
5 |
Correct |
68 ms |
150568 KB |
Output is correct |
6 |
Correct |
68 ms |
150608 KB |
Output is correct |
7 |
Correct |
65 ms |
150612 KB |
Output is correct |
8 |
Correct |
66 ms |
150800 KB |
Output is correct |
9 |
Correct |
70 ms |
150596 KB |
Output is correct |
10 |
Correct |
78 ms |
150556 KB |
Output is correct |
11 |
Correct |
73 ms |
150764 KB |
Output is correct |
12 |
Correct |
67 ms |
150608 KB |
Output is correct |
13 |
Correct |
71 ms |
150868 KB |
Output is correct |
14 |
Correct |
71 ms |
152096 KB |
Output is correct |
15 |
Correct |
71 ms |
150608 KB |
Output is correct |
16 |
Correct |
72 ms |
152096 KB |
Output is correct |
17 |
Correct |
65 ms |
150540 KB |
Output is correct |
18 |
Correct |
79 ms |
152076 KB |
Output is correct |
19 |
Correct |
73 ms |
151316 KB |
Output is correct |
20 |
Correct |
77 ms |
152000 KB |
Output is correct |
21 |
Correct |
78 ms |
152132 KB |
Output is correct |
22 |
Correct |
72 ms |
152192 KB |
Output is correct |
23 |
Correct |
74 ms |
152016 KB |
Output is correct |
24 |
Correct |
91 ms |
154416 KB |
Output is correct |
25 |
Correct |
78 ms |
151436 KB |
Output is correct |
26 |
Correct |
73 ms |
152180 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
68 ms |
150504 KB |
Output is correct |
2 |
Correct |
67 ms |
150436 KB |
Output is correct |
3 |
Correct |
73 ms |
150400 KB |
Output is correct |
4 |
Correct |
68 ms |
150608 KB |
Output is correct |
5 |
Correct |
68 ms |
150568 KB |
Output is correct |
6 |
Correct |
68 ms |
150608 KB |
Output is correct |
7 |
Correct |
65 ms |
150612 KB |
Output is correct |
8 |
Correct |
66 ms |
150800 KB |
Output is correct |
9 |
Correct |
70 ms |
150596 KB |
Output is correct |
10 |
Correct |
78 ms |
150556 KB |
Output is correct |
11 |
Correct |
73 ms |
150764 KB |
Output is correct |
12 |
Correct |
67 ms |
150608 KB |
Output is correct |
13 |
Correct |
71 ms |
150868 KB |
Output is correct |
14 |
Correct |
71 ms |
152096 KB |
Output is correct |
15 |
Correct |
71 ms |
150608 KB |
Output is correct |
16 |
Correct |
72 ms |
152096 KB |
Output is correct |
17 |
Correct |
65 ms |
150540 KB |
Output is correct |
18 |
Correct |
79 ms |
152076 KB |
Output is correct |
19 |
Correct |
73 ms |
151316 KB |
Output is correct |
20 |
Correct |
77 ms |
152000 KB |
Output is correct |
21 |
Correct |
78 ms |
152132 KB |
Output is correct |
22 |
Correct |
72 ms |
152192 KB |
Output is correct |
23 |
Correct |
74 ms |
152016 KB |
Output is correct |
24 |
Correct |
91 ms |
154416 KB |
Output is correct |
25 |
Correct |
78 ms |
151436 KB |
Output is correct |
26 |
Correct |
73 ms |
152180 KB |
Output is correct |
27 |
Execution timed out |
2457 ms |
274432 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |