/*
//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\
\\ //
// 271828___182845__904523__53602__ \\
\\ 87___47____13______52____66__24_ //
// 97___75____72______47____09___36 \\
\\ 999595_____74______96____69___67 //
// 62___77____24______07____66__30_ \\
\\ 35___35____47______59____45713__ //
// \\
\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\//
*/
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <climits>
#include <algorithm>
#include <random>
#include <queue>
#include <deque>
#include <iomanip>
#include <string>
#include <tuple>
#include <bitset>
#include <chrono>
#include <ctime>
#include <fstream>
#include <stack>
#include <cstdio>
using namespace std;
using ll = long long;
const int N = 3e5 + 5;
const ll mod = 1e9 + 7, inf = 1e18;
void solve() {
int n, m; cin >> n >> m;
vector<string> v(n);
for (int i = 0; i < n; ++i) cin >> v[i];
vector<ll> cnt_o(n), cnt_i(m);
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
if (v[i][j] == 'O') ++cnt_o[i];
}
}
for (int j = 0; j < m; ++j) {
for (int i = 0; i < n; ++i) {
if (v[i][j] == 'I') ++cnt_i[j];
}
}
ll ans = 0;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
if (v[i][j] == 'J') {
ans += cnt_i[j] * cnt_o[i];
}
else if (v[i][j] == 'O') --cnt_o[i];
else --cnt_i[j];
}
}
cout << ans;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
//int t; cin >> t;
//while (t--)
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
324 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
324 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
4 ms |
636 KB |
Output is correct |
15 |
Correct |
0 ms |
324 KB |
Output is correct |
16 |
Correct |
1 ms |
592 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
5 ms |
764 KB |
Output is correct |
19 |
Correct |
3 ms |
724 KB |
Output is correct |
20 |
Correct |
2 ms |
712 KB |
Output is correct |
21 |
Correct |
5 ms |
844 KB |
Output is correct |
22 |
Correct |
2 ms |
716 KB |
Output is correct |
23 |
Correct |
2 ms |
816 KB |
Output is correct |
24 |
Correct |
4 ms |
840 KB |
Output is correct |
25 |
Correct |
3 ms |
724 KB |
Output is correct |
26 |
Correct |
2 ms |
712 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
324 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
4 ms |
636 KB |
Output is correct |
15 |
Correct |
0 ms |
324 KB |
Output is correct |
16 |
Correct |
1 ms |
592 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
5 ms |
764 KB |
Output is correct |
19 |
Correct |
3 ms |
724 KB |
Output is correct |
20 |
Correct |
2 ms |
712 KB |
Output is correct |
21 |
Correct |
5 ms |
844 KB |
Output is correct |
22 |
Correct |
2 ms |
716 KB |
Output is correct |
23 |
Correct |
2 ms |
816 KB |
Output is correct |
24 |
Correct |
4 ms |
840 KB |
Output is correct |
25 |
Correct |
3 ms |
724 KB |
Output is correct |
26 |
Correct |
2 ms |
712 KB |
Output is correct |
27 |
Correct |
166 ms |
17884 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
5 ms |
1612 KB |
Output is correct |
30 |
Correct |
1 ms |
328 KB |
Output is correct |
31 |
Correct |
109 ms |
13188 KB |
Output is correct |
32 |
Correct |
104 ms |
18876 KB |
Output is correct |
33 |
Correct |
78 ms |
18916 KB |
Output is correct |
34 |
Correct |
128 ms |
15144 KB |
Output is correct |
35 |
Correct |
95 ms |
18736 KB |
Output is correct |
36 |
Correct |
83 ms |
19032 KB |
Output is correct |
37 |
Correct |
165 ms |
18984 KB |
Output is correct |
38 |
Correct |
58 ms |
13104 KB |
Output is correct |
39 |
Correct |
43 ms |
13144 KB |
Output is correct |