#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int h, w;
cin >> h >> w;
vector<string> v(h);
for (int i = 0; i < h;++i){
cin >> v[i];
}
vector<vector<int>> prefo(h, vector<int> (w));
vector<vector<int>> prefi(h, vector<int> (w));
for (int i = 0; i < w; ++i){
for (int j = 1; j < h; ++j){
if (v[j][i] == 'I')prefi[j][i] = prefi[j-1][i]+1;
else prefi[j][i] = prefi[j-1][i];
}
}
for (int i = 0; i < h; ++i){
for (int j = 1; j < w; ++j){
if (v[i][j] == 'O')prefo[i][j] = prefo[i][j-1]+1;
else prefo[i][j] = prefo[i][j-1];
}
}
int ans = 0;
for (int i = 0; i < h-1; ++i){
for (int j = 0; j < w-1; ++j){
if (v[i][j] == 'J'){
ans += (prefo[i][w-1]-prefo[i][j]) * (prefi[h-1][j] - prefi[i][j]);
}
}
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
312 KB |
Output is correct |
3 |
Correct |
0 ms |
312 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
1 ms |
432 KB |
Output is correct |
7 |
Correct |
0 ms |
448 KB |
Output is correct |
8 |
Correct |
1 ms |
440 KB |
Output is correct |
9 |
Correct |
1 ms |
460 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
1 ms |
444 KB |
Output is correct |
13 |
Correct |
1 ms |
448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
312 KB |
Output is correct |
3 |
Correct |
0 ms |
312 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
1 ms |
432 KB |
Output is correct |
7 |
Correct |
0 ms |
448 KB |
Output is correct |
8 |
Correct |
1 ms |
440 KB |
Output is correct |
9 |
Correct |
1 ms |
460 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
1 ms |
444 KB |
Output is correct |
13 |
Correct |
1 ms |
448 KB |
Output is correct |
14 |
Correct |
6 ms |
3640 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
3 ms |
2508 KB |
Output is correct |
17 |
Correct |
0 ms |
332 KB |
Output is correct |
18 |
Correct |
6 ms |
4676 KB |
Output is correct |
19 |
Correct |
4 ms |
4568 KB |
Output is correct |
20 |
Correct |
5 ms |
4684 KB |
Output is correct |
21 |
Correct |
6 ms |
4672 KB |
Output is correct |
22 |
Correct |
4 ms |
4540 KB |
Output is correct |
23 |
Correct |
5 ms |
4676 KB |
Output is correct |
24 |
Correct |
6 ms |
4696 KB |
Output is correct |
25 |
Correct |
5 ms |
4556 KB |
Output is correct |
26 |
Correct |
5 ms |
4684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
312 KB |
Output is correct |
3 |
Correct |
0 ms |
312 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
1 ms |
432 KB |
Output is correct |
7 |
Correct |
0 ms |
448 KB |
Output is correct |
8 |
Correct |
1 ms |
440 KB |
Output is correct |
9 |
Correct |
1 ms |
460 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
1 ms |
444 KB |
Output is correct |
13 |
Correct |
1 ms |
448 KB |
Output is correct |
14 |
Correct |
6 ms |
3640 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
3 ms |
2508 KB |
Output is correct |
17 |
Correct |
0 ms |
332 KB |
Output is correct |
18 |
Correct |
6 ms |
4676 KB |
Output is correct |
19 |
Correct |
4 ms |
4568 KB |
Output is correct |
20 |
Correct |
5 ms |
4684 KB |
Output is correct |
21 |
Correct |
6 ms |
4672 KB |
Output is correct |
22 |
Correct |
4 ms |
4540 KB |
Output is correct |
23 |
Correct |
5 ms |
4676 KB |
Output is correct |
24 |
Correct |
6 ms |
4696 KB |
Output is correct |
25 |
Correct |
5 ms |
4556 KB |
Output is correct |
26 |
Correct |
5 ms |
4684 KB |
Output is correct |
27 |
Correct |
255 ms |
151196 KB |
Output is correct |
28 |
Correct |
2 ms |
832 KB |
Output is correct |
29 |
Correct |
11 ms |
11828 KB |
Output is correct |
30 |
Correct |
1 ms |
716 KB |
Output is correct |
31 |
Correct |
179 ms |
111200 KB |
Output is correct |
32 |
Correct |
225 ms |
158948 KB |
Output is correct |
33 |
Correct |
226 ms |
159528 KB |
Output is correct |
34 |
Correct |
206 ms |
128836 KB |
Output is correct |
35 |
Correct |
238 ms |
158908 KB |
Output is correct |
36 |
Correct |
225 ms |
159540 KB |
Output is correct |
37 |
Correct |
279 ms |
160064 KB |
Output is correct |
38 |
Correct |
171 ms |
110320 KB |
Output is correct |
39 |
Correct |
144 ms |
110660 KB |
Output is correct |