#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;
int 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){
int 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 |
1 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 |
1 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 |
1 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 |
1 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 |
1 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 |
1 ms |
620 KB |
Output is correct |
14 |
Correct |
11 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 |
2 ms |
364 KB |
Output is correct |
18 |
Correct |
10 ms |
3692 KB |
Output is correct |
19 |
Correct |
10 ms |
3692 KB |
Output is correct |
20 |
Incorrect |
12 ms |
3692 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
1 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 |
1 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 |
1 ms |
620 KB |
Output is correct |
14 |
Correct |
11 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 |
2 ms |
364 KB |
Output is correct |
18 |
Correct |
10 ms |
3692 KB |
Output is correct |
19 |
Correct |
10 ms |
3692 KB |
Output is correct |
20 |
Incorrect |
12 ms |
3692 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |