#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define mp make_pair
#define pb push_back
using namespace std;
ll n, m, rez = 0;
char mat[3030][3030];
int main(){
cin>>n>>m;
for(int i = 0; i < n; i++){
string a;
cin>>a;
for(int j = 0; j < m; j++){
mat[i][j] = a[j];
}
}
int row[n][m], col[n][m];
memset(row,0,sizeof(row));
for(int i = 0; i < n;i++){
int cur = 0;
for(int j = m - 1; j >= 0; j--){
if(mat[i][j]=='O')
cur++;
row[i][j] = cur;
}
}
memset(col,0,sizeof(col));
for(int j = 0; j < m; j++){
int cur = 0;
for(int i = n - 1; i >= 0; i--){
if(mat[i][j] == 'I')
cur++;
col[i][j] = cur;
}
}
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
if(mat[i][j] == 'J' && i + 1 < n && j + 1 < m){
ll lcnt = row[i][j+1], kcnt = col[i + 1][j];
rez += (kcnt * lcnt);
}
else
continue;
}
}
cout<<rez<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
2 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
748 KB |
Output is correct |
6 |
Correct |
2 ms |
620 KB |
Output is correct |
7 |
Correct |
1 ms |
620 KB |
Output is correct |
8 |
Correct |
2 ms |
748 KB |
Output is correct |
9 |
Correct |
1 ms |
620 KB |
Output is correct |
10 |
Correct |
2 ms |
620 KB |
Output is correct |
11 |
Correct |
2 ms |
748 KB |
Output is correct |
12 |
Correct |
2 ms |
620 KB |
Output is correct |
13 |
Correct |
2 ms |
620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
2 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
748 KB |
Output is correct |
6 |
Correct |
2 ms |
620 KB |
Output is correct |
7 |
Correct |
1 ms |
620 KB |
Output is correct |
8 |
Correct |
2 ms |
748 KB |
Output is correct |
9 |
Correct |
1 ms |
620 KB |
Output is correct |
10 |
Correct |
2 ms |
620 KB |
Output is correct |
11 |
Correct |
2 ms |
748 KB |
Output is correct |
12 |
Correct |
2 ms |
620 KB |
Output is correct |
13 |
Correct |
2 ms |
620 KB |
Output is correct |
14 |
Correct |
13 ms |
3308 KB |
Output is correct |
15 |
Correct |
2 ms |
1644 KB |
Output is correct |
16 |
Correct |
5 ms |
2156 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
10 ms |
3748 KB |
Output is correct |
19 |
Correct |
9 ms |
3692 KB |
Output is correct |
20 |
Correct |
9 ms |
3692 KB |
Output is correct |
21 |
Correct |
10 ms |
3948 KB |
Output is correct |
22 |
Correct |
10 ms |
3948 KB |
Output is correct |
23 |
Correct |
10 ms |
3948 KB |
Output is correct |
24 |
Correct |
16 ms |
3948 KB |
Output is correct |
25 |
Correct |
10 ms |
3948 KB |
Output is correct |
26 |
Correct |
10 ms |
3948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
2 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
748 KB |
Output is correct |
6 |
Correct |
2 ms |
620 KB |
Output is correct |
7 |
Correct |
1 ms |
620 KB |
Output is correct |
8 |
Correct |
2 ms |
748 KB |
Output is correct |
9 |
Correct |
1 ms |
620 KB |
Output is correct |
10 |
Correct |
2 ms |
620 KB |
Output is correct |
11 |
Correct |
2 ms |
748 KB |
Output is correct |
12 |
Correct |
2 ms |
620 KB |
Output is correct |
13 |
Correct |
2 ms |
620 KB |
Output is correct |
14 |
Correct |
13 ms |
3308 KB |
Output is correct |
15 |
Correct |
2 ms |
1644 KB |
Output is correct |
16 |
Correct |
5 ms |
2156 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
10 ms |
3748 KB |
Output is correct |
19 |
Correct |
9 ms |
3692 KB |
Output is correct |
20 |
Correct |
9 ms |
3692 KB |
Output is correct |
21 |
Correct |
10 ms |
3948 KB |
Output is correct |
22 |
Correct |
10 ms |
3948 KB |
Output is correct |
23 |
Correct |
10 ms |
3948 KB |
Output is correct |
24 |
Correct |
16 ms |
3948 KB |
Output is correct |
25 |
Correct |
10 ms |
3948 KB |
Output is correct |
26 |
Correct |
10 ms |
3948 KB |
Output is correct |
27 |
Correct |
442 ms |
80364 KB |
Output is correct |
28 |
Correct |
6 ms |
7404 KB |
Output is correct |
29 |
Correct |
22 ms |
6764 KB |
Output is correct |
30 |
Correct |
2 ms |
492 KB |
Output is correct |
31 |
Correct |
330 ms |
60124 KB |
Output is correct |
32 |
Correct |
439 ms |
84436 KB |
Output is correct |
33 |
Correct |
428 ms |
83948 KB |
Output is correct |
34 |
Correct |
373 ms |
69008 KB |
Output is correct |
35 |
Correct |
437 ms |
83692 KB |
Output is correct |
36 |
Correct |
432 ms |
84460 KB |
Output is correct |
37 |
Correct |
473 ms |
84560 KB |
Output is correct |
38 |
Correct |
298 ms |
59628 KB |
Output is correct |
39 |
Correct |
302 ms |
59896 KB |
Output is correct |