#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <deque>
#include <map>
#include <set>
#include <complex>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <random>
#define ft first
#define sc second
#define pb push_back
#define len(v) (int)v.size()
#define int ll
using namespace std;
typedef long long ll;
signed main() {
#ifdef PC
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int h, w;
cin >> h >> w;
vector<vector<char>> mat(h, vector<char>(w));
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
cin >> mat[i][j];
}
}
int ans = 0;
vector<int> have(w, 0);
for (int i = h - 1; i >= 0; i--) {
int now = 0;
for (int j = w - 1; j >= 0; j--) {
if(mat[i][j] == 'I')
have[j]++;
if(mat[i][j] == 'O')
now++;
if(mat[i][j] == 'J') {
ans += have[j] * now;
}
}
}
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
9 ms |
768 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
7 ms |
640 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
10 ms |
768 KB |
Output is correct |
19 |
Correct |
8 ms |
896 KB |
Output is correct |
20 |
Correct |
8 ms |
768 KB |
Output is correct |
21 |
Correct |
10 ms |
896 KB |
Output is correct |
22 |
Correct |
8 ms |
768 KB |
Output is correct |
23 |
Correct |
8 ms |
768 KB |
Output is correct |
24 |
Correct |
10 ms |
896 KB |
Output is correct |
25 |
Correct |
8 ms |
768 KB |
Output is correct |
26 |
Correct |
8 ms |
896 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
9 ms |
768 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
7 ms |
640 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
10 ms |
768 KB |
Output is correct |
19 |
Correct |
8 ms |
896 KB |
Output is correct |
20 |
Correct |
8 ms |
768 KB |
Output is correct |
21 |
Correct |
10 ms |
896 KB |
Output is correct |
22 |
Correct |
8 ms |
768 KB |
Output is correct |
23 |
Correct |
8 ms |
768 KB |
Output is correct |
24 |
Correct |
10 ms |
896 KB |
Output is correct |
25 |
Correct |
8 ms |
768 KB |
Output is correct |
26 |
Correct |
8 ms |
896 KB |
Output is correct |
27 |
Correct |
187 ms |
17144 KB |
Output is correct |
28 |
Correct |
5 ms |
512 KB |
Output is correct |
29 |
Correct |
16 ms |
1664 KB |
Output is correct |
30 |
Correct |
5 ms |
384 KB |
Output is correct |
31 |
Correct |
143 ms |
12664 KB |
Output is correct |
32 |
Correct |
150 ms |
17916 KB |
Output is correct |
33 |
Correct |
140 ms |
17912 KB |
Output is correct |
34 |
Correct |
162 ms |
14584 KB |
Output is correct |
35 |
Correct |
146 ms |
17784 KB |
Output is correct |
36 |
Correct |
145 ms |
17912 KB |
Output is correct |
37 |
Correct |
190 ms |
17912 KB |
Output is correct |
38 |
Correct |
103 ms |
12536 KB |
Output is correct |
39 |
Correct |
101 ms |
12664 KB |
Output is correct |