/*input
4 4
JJOO
JJOO
IIJO
IIIJ
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
ios_base::sync_with_stdio(false);
int n, m;
cin >> n >> m;
string s[n];
for (int i = 0; i < n; i++)
cin >> s[i];
ll ans = 0;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
if (s[i][j] != 'J')
continue;
ll O = 0;
ll I = 0;
for (int a = i + 1; a < n; a++)
I += (s[a][j] == 'I');
for (int a = j + 1; a < m; a++)
O += (s[i][a] == 'O');
ans += O * I;
}
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
32 ms |
768 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
18 ms |
640 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
47 ms |
896 KB |
Output is correct |
19 |
Correct |
13 ms |
768 KB |
Output is correct |
20 |
Correct |
58 ms |
896 KB |
Output is correct |
21 |
Correct |
47 ms |
896 KB |
Output is correct |
22 |
Correct |
47 ms |
768 KB |
Output is correct |
23 |
Correct |
57 ms |
896 KB |
Output is correct |
24 |
Correct |
57 ms |
896 KB |
Output is correct |
25 |
Correct |
14 ms |
896 KB |
Output is correct |
26 |
Correct |
58 ms |
868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
32 ms |
768 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
18 ms |
640 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
47 ms |
896 KB |
Output is correct |
19 |
Correct |
13 ms |
768 KB |
Output is correct |
20 |
Correct |
58 ms |
896 KB |
Output is correct |
21 |
Correct |
47 ms |
896 KB |
Output is correct |
22 |
Correct |
47 ms |
768 KB |
Output is correct |
23 |
Correct |
57 ms |
896 KB |
Output is correct |
24 |
Correct |
57 ms |
896 KB |
Output is correct |
25 |
Correct |
14 ms |
896 KB |
Output is correct |
26 |
Correct |
58 ms |
868 KB |
Output is correct |
27 |
Execution timed out |
1073 ms |
14692 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |