#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
const int mod = 1e9 + 7;
const int N = 3000;
int n, m;
char a[N][N];
signed main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> m;
for(int i = 0;i < n; i++){
for(int j = 0;j < m; j++){
cin >> a[i][j];
}
}
vector<int> col_I(m, 0);
for(int j = 0;j < m; j++){
for(int i = 0;i < n; i++){
col_I[j]+= (a[i][j] == 'I');
}
}
vector<int> row_O(n, 0);
for(int i = 0; i < n; i++){
for(int j = 0;j < m; j++) row_O[i]+= (a[i][j] == 'O');
}
int ans = 0;
for(int i = 0;i < n; i++){
for(int j = 0;j < m; j++){
col_I[j]-= (a[i][j] == 'I');
row_O[i]-= (a[i][j] == 'O');
if(a[i][j] == 'J'){
int I = col_I[j];
int O = row_O[i];
// cout << i+1 << ' ' << j+1 << " = " << I << '\n';
//cout << i+1 << ' ' << j+1 << " = " << O << '\n';
ans+= O*I;
}
}
}
cout << ans;
return 0;
}
# |
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 |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
2516 KB |
Output is correct |
6 |
Correct |
1 ms |
2648 KB |
Output is correct |
7 |
Correct |
2 ms |
2648 KB |
Output is correct |
8 |
Correct |
1 ms |
2652 KB |
Output is correct |
9 |
Correct |
1 ms |
2652 KB |
Output is correct |
10 |
Correct |
1 ms |
2652 KB |
Output is correct |
11 |
Correct |
1 ms |
2648 KB |
Output is correct |
12 |
Correct |
1 ms |
2652 KB |
Output is correct |
13 |
Correct |
1 ms |
2652 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 |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
2516 KB |
Output is correct |
6 |
Correct |
1 ms |
2648 KB |
Output is correct |
7 |
Correct |
2 ms |
2648 KB |
Output is correct |
8 |
Correct |
1 ms |
2652 KB |
Output is correct |
9 |
Correct |
1 ms |
2652 KB |
Output is correct |
10 |
Correct |
1 ms |
2652 KB |
Output is correct |
11 |
Correct |
1 ms |
2648 KB |
Output is correct |
12 |
Correct |
1 ms |
2652 KB |
Output is correct |
13 |
Correct |
1 ms |
2652 KB |
Output is correct |
14 |
Correct |
3 ms |
2648 KB |
Output is correct |
15 |
Correct |
1 ms |
2652 KB |
Output is correct |
16 |
Correct |
2 ms |
2652 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
4 ms |
2908 KB |
Output is correct |
19 |
Correct |
3 ms |
2924 KB |
Output is correct |
20 |
Correct |
5 ms |
2936 KB |
Output is correct |
21 |
Correct |
4 ms |
2908 KB |
Output is correct |
22 |
Correct |
3 ms |
2724 KB |
Output is correct |
23 |
Correct |
3 ms |
2908 KB |
Output is correct |
24 |
Correct |
4 ms |
2908 KB |
Output is correct |
25 |
Correct |
3 ms |
2744 KB |
Output is correct |
26 |
Correct |
4 ms |
2908 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 |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
2516 KB |
Output is correct |
6 |
Correct |
1 ms |
2648 KB |
Output is correct |
7 |
Correct |
2 ms |
2648 KB |
Output is correct |
8 |
Correct |
1 ms |
2652 KB |
Output is correct |
9 |
Correct |
1 ms |
2652 KB |
Output is correct |
10 |
Correct |
1 ms |
2652 KB |
Output is correct |
11 |
Correct |
1 ms |
2648 KB |
Output is correct |
12 |
Correct |
1 ms |
2652 KB |
Output is correct |
13 |
Correct |
1 ms |
2652 KB |
Output is correct |
14 |
Correct |
3 ms |
2648 KB |
Output is correct |
15 |
Correct |
1 ms |
2652 KB |
Output is correct |
16 |
Correct |
2 ms |
2652 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
4 ms |
2908 KB |
Output is correct |
19 |
Correct |
3 ms |
2924 KB |
Output is correct |
20 |
Correct |
5 ms |
2936 KB |
Output is correct |
21 |
Correct |
4 ms |
2908 KB |
Output is correct |
22 |
Correct |
3 ms |
2724 KB |
Output is correct |
23 |
Correct |
3 ms |
2908 KB |
Output is correct |
24 |
Correct |
4 ms |
2908 KB |
Output is correct |
25 |
Correct |
3 ms |
2744 KB |
Output is correct |
26 |
Correct |
4 ms |
2908 KB |
Output is correct |
27 |
Correct |
122 ms |
17492 KB |
Output is correct |
28 |
Correct |
1 ms |
8792 KB |
Output is correct |
29 |
Correct |
8 ms |
3164 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
109 ms |
15068 KB |
Output is correct |
32 |
Correct |
109 ms |
17888 KB |
Output is correct |
33 |
Correct |
108 ms |
18000 KB |
Output is correct |
34 |
Correct |
103 ms |
16084 KB |
Output is correct |
35 |
Correct |
115 ms |
18260 KB |
Output is correct |
36 |
Correct |
111 ms |
18004 KB |
Output is correct |
37 |
Correct |
148 ms |
18000 KB |
Output is correct |
38 |
Correct |
77 ms |
14680 KB |
Output is correct |
39 |
Correct |
81 ms |
14944 KB |
Output is correct |