#include <bits/stdc++.h>
using namespace std;
#define ll long long
void init() {
}
void solve() {
int h, w;
cin >> h >> w;
string a[h];
for (int i = 0; i < h; i++) cin >> a[i];
ll int ans = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (a[i][j] == 'J') {
int cnt1 = 0, cnt2 = 0;
for (int k = i + 1; k < h; k++) cnt1 += (a[k][j] == 'I');
for (int k = j + 1; k < w; k++) cnt2 += (a[i][k] == 'O');
ans += cnt1 * cnt2;
}
}
}
cout << ans << endl;
}
int main() {
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// #endif
ios::sync_with_stdio(false); cin.tie(0);
init();
solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
324 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
324 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
28 ms |
716 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
16 ms |
588 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
48 ms |
824 KB |
Output is correct |
19 |
Correct |
11 ms |
756 KB |
Output is correct |
20 |
Correct |
47 ms |
804 KB |
Output is correct |
21 |
Correct |
42 ms |
820 KB |
Output is correct |
22 |
Correct |
42 ms |
852 KB |
Output is correct |
23 |
Correct |
55 ms |
808 KB |
Output is correct |
24 |
Correct |
49 ms |
724 KB |
Output is correct |
25 |
Correct |
11 ms |
724 KB |
Output is correct |
26 |
Correct |
46 ms |
804 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
324 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
28 ms |
716 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
16 ms |
588 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
48 ms |
824 KB |
Output is correct |
19 |
Correct |
11 ms |
756 KB |
Output is correct |
20 |
Correct |
47 ms |
804 KB |
Output is correct |
21 |
Correct |
42 ms |
820 KB |
Output is correct |
22 |
Correct |
42 ms |
852 KB |
Output is correct |
23 |
Correct |
55 ms |
808 KB |
Output is correct |
24 |
Correct |
49 ms |
724 KB |
Output is correct |
25 |
Correct |
11 ms |
724 KB |
Output is correct |
26 |
Correct |
46 ms |
804 KB |
Output is correct |
27 |
Execution timed out |
1101 ms |
17804 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |