#include <bits/stdc++.h>
#define int long long
#define moony long long
#define pii pair<int, int>
#define fi first
#define se second
#define ld long double
#define vi vector<int>
#define vii vector<vector<int>>
#define all(v) (v).begin(), (v).end()
#define rep(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define per(i, b, a) for (int i = (b), _a = (a); i >= _a; --i)
using namespace std;
const int MOD = 1e9 + 7;
int add(int a, int b) {
a += b;
if (a >= MOD) a -= MOD;
return a;
}
int mul(int a, int b) {
(a *= b) %= MOD;
return a;
}
int ceil(int x, int y) {
return (x + y - 1) / y;
}
int bin_pow(int x, int y) {
int res = 1;
while (y) {
if (y & 1) res = res * x % MOD;
x = x * x % MOD;
y >>= 1;
}
return res;
}
template<class T> bool minimize(T& a, T b) {
if (a > b) return a = b, true;
return false;
}
template<class T> bool maximize(T& a, T b) {
if (a < b) return a = b, true;
return false;
}
const int INF = 1e17;
const int maxn = 3e3 + 5;
int n, m, ans;
int a[maxn + 5][maxn + 5];
string s[maxn + 5];
void solve(int tc) {
cin >> n >> m;
for (int i = 1; i <= n; ++i) {
cin >> s[i];
s[i] = " " + s[i];
for (int j = m, cnt = 0; j >= 1; --j) {
if (s[i][j] == 'O') cnt++;
if (s[i][j] == 'J')
a[i][j] = cnt;
}
}
for (int j = 1; j <= m; ++j) {
for (int i = n, cnt = 0; i >= 1; --i) {
if (s[i][j] == 'I') cnt++;
if (s[i][j] == 'J')
ans += a[i][j] * cnt;
}
}
cout << ans;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int tc = 1;
//cin >> tc;
for (int i = 1; i <= tc; ++i) {
solve(i);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
860 KB |
Output is correct |
6 |
Correct |
1 ms |
860 KB |
Output is correct |
7 |
Correct |
1 ms |
860 KB |
Output is correct |
8 |
Correct |
1 ms |
860 KB |
Output is correct |
9 |
Correct |
1 ms |
860 KB |
Output is correct |
10 |
Correct |
0 ms |
860 KB |
Output is correct |
11 |
Correct |
0 ms |
860 KB |
Output is correct |
12 |
Correct |
1 ms |
860 KB |
Output is correct |
13 |
Correct |
1 ms |
820 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
860 KB |
Output is correct |
6 |
Correct |
1 ms |
860 KB |
Output is correct |
7 |
Correct |
1 ms |
860 KB |
Output is correct |
8 |
Correct |
1 ms |
860 KB |
Output is correct |
9 |
Correct |
1 ms |
860 KB |
Output is correct |
10 |
Correct |
0 ms |
860 KB |
Output is correct |
11 |
Correct |
0 ms |
860 KB |
Output is correct |
12 |
Correct |
1 ms |
860 KB |
Output is correct |
13 |
Correct |
1 ms |
820 KB |
Output is correct |
14 |
Correct |
5 ms |
4308 KB |
Output is correct |
15 |
Correct |
1 ms |
2140 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
0 ms |
600 KB |
Output is correct |
18 |
Correct |
5 ms |
4956 KB |
Output is correct |
19 |
Correct |
2 ms |
3900 KB |
Output is correct |
20 |
Correct |
2 ms |
3676 KB |
Output is correct |
21 |
Correct |
5 ms |
4956 KB |
Output is correct |
22 |
Correct |
3 ms |
4188 KB |
Output is correct |
23 |
Correct |
2 ms |
3672 KB |
Output is correct |
24 |
Correct |
7 ms |
4956 KB |
Output is correct |
25 |
Correct |
2 ms |
3932 KB |
Output is correct |
26 |
Correct |
2 ms |
3676 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
860 KB |
Output is correct |
6 |
Correct |
1 ms |
860 KB |
Output is correct |
7 |
Correct |
1 ms |
860 KB |
Output is correct |
8 |
Correct |
1 ms |
860 KB |
Output is correct |
9 |
Correct |
1 ms |
860 KB |
Output is correct |
10 |
Correct |
0 ms |
860 KB |
Output is correct |
11 |
Correct |
0 ms |
860 KB |
Output is correct |
12 |
Correct |
1 ms |
860 KB |
Output is correct |
13 |
Correct |
1 ms |
820 KB |
Output is correct |
14 |
Correct |
5 ms |
4308 KB |
Output is correct |
15 |
Correct |
1 ms |
2140 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
0 ms |
600 KB |
Output is correct |
18 |
Correct |
5 ms |
4956 KB |
Output is correct |
19 |
Correct |
2 ms |
3900 KB |
Output is correct |
20 |
Correct |
2 ms |
3676 KB |
Output is correct |
21 |
Correct |
5 ms |
4956 KB |
Output is correct |
22 |
Correct |
3 ms |
4188 KB |
Output is correct |
23 |
Correct |
2 ms |
3672 KB |
Output is correct |
24 |
Correct |
7 ms |
4956 KB |
Output is correct |
25 |
Correct |
2 ms |
3932 KB |
Output is correct |
26 |
Correct |
2 ms |
3676 KB |
Output is correct |
27 |
Correct |
174 ms |
87744 KB |
Output is correct |
28 |
Correct |
5 ms |
9308 KB |
Output is correct |
29 |
Correct |
4 ms |
4700 KB |
Output is correct |
30 |
Correct |
1 ms |
828 KB |
Output is correct |
31 |
Correct |
121 ms |
71612 KB |
Output is correct |
32 |
Correct |
70 ms |
66288 KB |
Output is correct |
33 |
Correct |
62 ms |
53584 KB |
Output is correct |
34 |
Correct |
131 ms |
83028 KB |
Output is correct |
35 |
Correct |
72 ms |
72272 KB |
Output is correct |
36 |
Correct |
65 ms |
53688 KB |
Output is correct |
37 |
Correct |
165 ms |
88916 KB |
Output is correct |
38 |
Correct |
44 ms |
49124 KB |
Output is correct |
39 |
Correct |
46 ms |
38996 KB |
Output is correct |