#include <bits/stdc++.h>
using namespace std;
const int nmax = 1e3 + 1;
char mat[nmax][nmax];
int O[nmax], I[nmax];
int main() {
int n, m;
cin >> n >> m;
for(int i = 1; i <= n; i ++) {
for(int j = 1; j <= m; j ++) {
cin >> mat[i][j];
}
}
long long ans = 0;
for(int i = n; i>=1; i--) {
for(int j=m; j>=1; j--) {
if(mat[i][j] == 'J') {
ans += (long long) I[j] * O[i];
// cout << i << " " << j << ": " << O[i] << " " << I[j] << endl;
}
if(mat[i][j] == 'O') {
O[i] ++;
}
if(mat[i][j] == 'I') {
I[j] ++;
}
}
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 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 |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 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 |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
8 ms |
1112 KB |
Output is correct |
15 |
Correct |
1 ms |
856 KB |
Output is correct |
16 |
Correct |
5 ms |
600 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
10 ms |
1056 KB |
Output is correct |
19 |
Correct |
8 ms |
1116 KB |
Output is correct |
20 |
Correct |
8 ms |
968 KB |
Output is correct |
21 |
Correct |
10 ms |
1184 KB |
Output is correct |
22 |
Correct |
8 ms |
964 KB |
Output is correct |
23 |
Correct |
9 ms |
1116 KB |
Output is correct |
24 |
Correct |
12 ms |
1112 KB |
Output is correct |
25 |
Correct |
9 ms |
1116 KB |
Output is correct |
26 |
Correct |
8 ms |
1112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 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 |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
8 ms |
1112 KB |
Output is correct |
15 |
Correct |
1 ms |
856 KB |
Output is correct |
16 |
Correct |
5 ms |
600 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
10 ms |
1056 KB |
Output is correct |
19 |
Correct |
8 ms |
1116 KB |
Output is correct |
20 |
Correct |
8 ms |
968 KB |
Output is correct |
21 |
Correct |
10 ms |
1184 KB |
Output is correct |
22 |
Correct |
8 ms |
964 KB |
Output is correct |
23 |
Correct |
9 ms |
1116 KB |
Output is correct |
24 |
Correct |
12 ms |
1112 KB |
Output is correct |
25 |
Correct |
9 ms |
1116 KB |
Output is correct |
26 |
Correct |
8 ms |
1112 KB |
Output is correct |
27 |
Runtime error |
90 ms |
5212 KB |
Execution killed with signal 11 |
28 |
Halted |
0 ms |
0 KB |
- |