#include <bits/stdc++.h>
using namespace std;
int main(){
cin.tie(0);
cin.sync_with_stdio(0);
int N, M;
cin >> N >> M;
vector<vector<char>> g(N, vector<char>(M));
vector<vector<int>> i(N, vector<int>(M, 0)), o(N, vector<int>(M, 0));
for(auto &i : g)
for(auto &j : i)
cin >> j;
int cont;
for(int ii=0; ii<N; ii++){
cont = 0;
for(int jj=M-1; jj>=0; jj--){
if(g[ii][jj] == 'O') cont ++;
if(g[ii][jj] == 'J') o[ii][jj] = cont;
}
}
for(int ii=0; ii<M; ii++){
cont = 0;
for(int jj=N-1; jj>=0; jj--){
if(g[jj][ii] == 'I') cont ++;
if(g[jj][ii] == 'J') i[jj][ii] = cont;
}
}
long long ans = 0;
for(int ii=0; ii<N; ii++){
for(int jj=0; jj<M; jj++) if(g[ii][jj] == 'J'){
ans += 1LL * i[ii][jj] * o[ii][jj];
// cout << ii << " " << jj << ": " << 1LL * i[ii][jj] * o[ii][jj] << "\n";
}
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
512 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
2 ms |
512 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
512 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
512 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
2 ms |
512 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
512 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
512 KB |
Output is correct |
14 |
Correct |
12 ms |
2304 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
6 ms |
1664 KB |
Output is correct |
17 |
Correct |
3 ms |
384 KB |
Output is correct |
18 |
Correct |
13 ms |
2788 KB |
Output is correct |
19 |
Correct |
12 ms |
2688 KB |
Output is correct |
20 |
Correct |
12 ms |
2816 KB |
Output is correct |
21 |
Correct |
12 ms |
2816 KB |
Output is correct |
22 |
Correct |
10 ms |
2688 KB |
Output is correct |
23 |
Correct |
8 ms |
2816 KB |
Output is correct |
24 |
Correct |
12 ms |
2816 KB |
Output is correct |
25 |
Correct |
11 ms |
2816 KB |
Output is correct |
26 |
Correct |
10 ms |
2816 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
512 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
2 ms |
512 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
512 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
512 KB |
Output is correct |
14 |
Correct |
12 ms |
2304 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
6 ms |
1664 KB |
Output is correct |
17 |
Correct |
3 ms |
384 KB |
Output is correct |
18 |
Correct |
13 ms |
2788 KB |
Output is correct |
19 |
Correct |
12 ms |
2688 KB |
Output is correct |
20 |
Correct |
12 ms |
2816 KB |
Output is correct |
21 |
Correct |
12 ms |
2816 KB |
Output is correct |
22 |
Correct |
10 ms |
2688 KB |
Output is correct |
23 |
Correct |
8 ms |
2816 KB |
Output is correct |
24 |
Correct |
12 ms |
2816 KB |
Output is correct |
25 |
Correct |
11 ms |
2816 KB |
Output is correct |
26 |
Correct |
10 ms |
2816 KB |
Output is correct |
27 |
Correct |
438 ms |
83796 KB |
Output is correct |
28 |
Correct |
5 ms |
896 KB |
Output is correct |
29 |
Correct |
20 ms |
6656 KB |
Output is correct |
30 |
Correct |
5 ms |
768 KB |
Output is correct |
31 |
Correct |
311 ms |
61916 KB |
Output is correct |
32 |
Correct |
283 ms |
88312 KB |
Output is correct |
33 |
Correct |
292 ms |
88440 KB |
Output is correct |
34 |
Correct |
417 ms |
71800 KB |
Output is correct |
35 |
Correct |
323 ms |
88244 KB |
Output is correct |
36 |
Correct |
288 ms |
88440 KB |
Output is correct |
37 |
Correct |
451 ms |
88696 KB |
Output is correct |
38 |
Correct |
215 ms |
61396 KB |
Output is correct |
39 |
Correct |
198 ms |
61688 KB |
Output is correct |