#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<utility>
#define int long long
#define INF 10000000000000000
#define MOD 1000000007
#define pii pair<long long, long long>
using namespace std;
signed main() {
int n, m;
cin >> n >> m;
vector<string>s(n);
for (auto &i : s) {
cin >> i;
}
vector<vector<pii> >dp(n+1, vector<pii>(m+1, {0, 0}));
for (int i = n-1 ; i >= 0 ; i--) {
for (int j = m-1 ; j >= 0 ; j--) {
dp[i][j] = {dp[i][j+1].first, dp[i+1][j].second};
if (s[i][j] == 'O') dp[i][j].first++;
else if (s[i][j] == 'I') dp[i][j].second++;
}
}
int ans = 0;
for (int i = 0 ; i < n ; i++) {
for (int j = 0 ; j < m ; j++) {
//cout << dp[i][j].first << " ";
if (s[i][j] == 'J') ans += dp[i][j].first * dp[i][j].second;
}
//cout << "\n";
}
cout << ans << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
396 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
396 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
14 |
Correct |
6 ms |
3676 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
2644 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
8 ms |
4956 KB |
Output is correct |
19 |
Correct |
6 ms |
4700 KB |
Output is correct |
20 |
Correct |
6 ms |
4956 KB |
Output is correct |
21 |
Correct |
8 ms |
4956 KB |
Output is correct |
22 |
Correct |
6 ms |
4700 KB |
Output is correct |
23 |
Correct |
6 ms |
4956 KB |
Output is correct |
24 |
Correct |
8 ms |
4956 KB |
Output is correct |
25 |
Correct |
6 ms |
4716 KB |
Output is correct |
26 |
Correct |
7 ms |
4948 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
396 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
14 |
Correct |
6 ms |
3676 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
2644 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
8 ms |
4956 KB |
Output is correct |
19 |
Correct |
6 ms |
4700 KB |
Output is correct |
20 |
Correct |
6 ms |
4956 KB |
Output is correct |
21 |
Correct |
8 ms |
4956 KB |
Output is correct |
22 |
Correct |
6 ms |
4700 KB |
Output is correct |
23 |
Correct |
6 ms |
4956 KB |
Output is correct |
24 |
Correct |
8 ms |
4956 KB |
Output is correct |
25 |
Correct |
6 ms |
4716 KB |
Output is correct |
26 |
Correct |
7 ms |
4948 KB |
Output is correct |
27 |
Correct |
250 ms |
153456 KB |
Output is correct |
28 |
Correct |
2 ms |
1116 KB |
Output is correct |
29 |
Correct |
15 ms |
12100 KB |
Output is correct |
30 |
Correct |
1 ms |
860 KB |
Output is correct |
31 |
Correct |
234 ms |
114104 KB |
Output is correct |
32 |
Correct |
203 ms |
160628 KB |
Output is correct |
33 |
Correct |
198 ms |
161104 KB |
Output is correct |
34 |
Correct |
208 ms |
132288 KB |
Output is correct |
35 |
Correct |
199 ms |
160596 KB |
Output is correct |
36 |
Correct |
199 ms |
161272 KB |
Output is correct |
37 |
Correct |
257 ms |
161616 KB |
Output is correct |
38 |
Correct |
139 ms |
113276 KB |
Output is correct |
39 |
Correct |
142 ms |
113620 KB |
Output is correct |