#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(), x.end()
#define size(x) (int)x.size()
template<class S, class T>
bool chmin(S &a, const T &b) {
return a > b && (a = b) == b;
}
template<class S, class T>
bool chmax(S &a, const T &b) {
return a < b && (a = b) == b;
}
const int inf = 1e9 + 7;
const int INF = 1e18 + 7;
const int mod = 1e9 + 7;
signed main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n, m; cin >> n >> m;
string s[n];
for (int i = 0; i < n; ++i) cin >> s[i];
int pref[n][m];
for (int i = 0; i < n; ++i) {
pref[i][0] = s[i][0] == 'O';
for (int j = 1; j < m; ++j) {
pref[i][j] = pref[i][j - 1] + (s[i][j] == 'O');
}
}
int res = 0;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
for (int k = i + 1; k < n; ++k) {
if (s[i][j] == 'J' && s[k][j] == 'I') {
res += pref[i][m - 1] - pref[i][j];
}
}
}
}
cout << res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
95 ms |
2140 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
17 ms |
1624 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
122 ms |
2908 KB |
Output is correct |
19 |
Correct |
44 ms |
2652 KB |
Output is correct |
20 |
Correct |
55 ms |
3104 KB |
Output is correct |
21 |
Correct |
122 ms |
2904 KB |
Output is correct |
22 |
Correct |
55 ms |
2808 KB |
Output is correct |
23 |
Correct |
55 ms |
2652 KB |
Output is correct |
24 |
Correct |
119 ms |
2904 KB |
Output is correct |
25 |
Correct |
45 ms |
2808 KB |
Output is correct |
26 |
Correct |
55 ms |
2648 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
95 ms |
2140 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
17 ms |
1624 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
122 ms |
2908 KB |
Output is correct |
19 |
Correct |
44 ms |
2652 KB |
Output is correct |
20 |
Correct |
55 ms |
3104 KB |
Output is correct |
21 |
Correct |
122 ms |
2904 KB |
Output is correct |
22 |
Correct |
55 ms |
2808 KB |
Output is correct |
23 |
Correct |
55 ms |
2652 KB |
Output is correct |
24 |
Correct |
119 ms |
2904 KB |
Output is correct |
25 |
Correct |
45 ms |
2808 KB |
Output is correct |
26 |
Correct |
55 ms |
2648 KB |
Output is correct |
27 |
Execution timed out |
1044 ms |
84304 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |