#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e3 + 123;
int n,m;
char a[3100][3100];
int so[N][N],si[N][N];
void test(){
cin >> n >> m;
for(int i=1;i<=n;i++){
for(int j = 1;j <= m;j++){
cin >> a[i][j];
}
}
for(int i = 1;i <= n;i++){
for(int j = m;j >= 1;j--){
so[i][j] = so[i][j + 1] + (a[i][j] == 'O');
}
}
for(int i = 1;i <= m;i++){
for(int j = n;j >= 1;j--){
si[j][i] = si[j + 1][i] + (a[j][i] == 'I');
}
}
ll res = 0;
for(int i = 1;i <= n;++i){
for(int j = 1;j <= m;j++){
if(a[i][j] == 'J'){
res += so[i][j + 1] * 1ll * si[i + 1][j];
}
}
}
cout << res;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
//cin >> t;
while(t--) test();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1492 KB |
Output is correct |
7 |
Correct |
1 ms |
1364 KB |
Output is correct |
8 |
Correct |
1 ms |
1484 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
2 ms |
1488 KB |
Output is correct |
12 |
Correct |
1 ms |
1476 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1492 KB |
Output is correct |
7 |
Correct |
1 ms |
1364 KB |
Output is correct |
8 |
Correct |
1 ms |
1484 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
2 ms |
1488 KB |
Output is correct |
12 |
Correct |
1 ms |
1476 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
14 |
Correct |
7 ms |
7556 KB |
Output is correct |
15 |
Correct |
2 ms |
4940 KB |
Output is correct |
16 |
Correct |
4 ms |
4252 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
8 ms |
8016 KB |
Output is correct |
19 |
Correct |
10 ms |
7884 KB |
Output is correct |
20 |
Correct |
7 ms |
7924 KB |
Output is correct |
21 |
Correct |
8 ms |
8020 KB |
Output is correct |
22 |
Correct |
7 ms |
7892 KB |
Output is correct |
23 |
Correct |
7 ms |
7868 KB |
Output is correct |
24 |
Correct |
8 ms |
8048 KB |
Output is correct |
25 |
Correct |
7 ms |
7924 KB |
Output is correct |
26 |
Correct |
7 ms |
7832 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Correct |
1 ms |
1492 KB |
Output is correct |
7 |
Correct |
1 ms |
1364 KB |
Output is correct |
8 |
Correct |
1 ms |
1484 KB |
Output is correct |
9 |
Correct |
1 ms |
1492 KB |
Output is correct |
10 |
Correct |
1 ms |
1364 KB |
Output is correct |
11 |
Correct |
2 ms |
1488 KB |
Output is correct |
12 |
Correct |
1 ms |
1476 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
14 |
Correct |
7 ms |
7556 KB |
Output is correct |
15 |
Correct |
2 ms |
4940 KB |
Output is correct |
16 |
Correct |
4 ms |
4252 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
8 ms |
8016 KB |
Output is correct |
19 |
Correct |
10 ms |
7884 KB |
Output is correct |
20 |
Correct |
7 ms |
7924 KB |
Output is correct |
21 |
Correct |
8 ms |
8020 KB |
Output is correct |
22 |
Correct |
7 ms |
7892 KB |
Output is correct |
23 |
Correct |
7 ms |
7868 KB |
Output is correct |
24 |
Correct |
8 ms |
8048 KB |
Output is correct |
25 |
Correct |
7 ms |
7924 KB |
Output is correct |
26 |
Correct |
7 ms |
7832 KB |
Output is correct |
27 |
Correct |
272 ms |
91084 KB |
Output is correct |
28 |
Correct |
11 ms |
26196 KB |
Output is correct |
29 |
Correct |
13 ms |
8000 KB |
Output is correct |
30 |
Correct |
1 ms |
596 KB |
Output is correct |
31 |
Correct |
196 ms |
75196 KB |
Output is correct |
32 |
Correct |
257 ms |
91516 KB |
Output is correct |
33 |
Correct |
247 ms |
91200 KB |
Output is correct |
34 |
Correct |
227 ms |
86988 KB |
Output is correct |
35 |
Correct |
219 ms |
91520 KB |
Output is correct |
36 |
Correct |
270 ms |
91216 KB |
Output is correct |
37 |
Correct |
308 ms |
91488 KB |
Output is correct |
38 |
Correct |
173 ms |
75048 KB |
Output is correct |
39 |
Correct |
197 ms |
74848 KB |
Output is correct |