#include <bits/stdc++.h>
typedef long double ld;
#define int long long
#define TC int t; cin >> t; for(int _=1; _<=t; _++)
#define bismillah ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
using namespace std;
const int N = 3007;
char a[N][N];
int prefo[N][N];
int prefi[N][N];
signed main(){
bismillah;
int n, m; cin >> n >> m;
for(int i=1; i<=n; i++){
for(int j=1; j<=m; j++){
cin >> a[i][j];
char c = a[i][j];
prefo[i][j]+=prefo[i][j-1];
prefi[i][j]+=prefi[i-1][j];
if(c=='O'){
prefo[i][j]++;
}else if(c=='I'){
prefi[i][j]++;
}
}
}
int ans = 0;
for(int i=1; i<=n; i++){
for(int j=1; j<=m; j++){
if(a[i][j]=='J'){
int O = prefo[i][m]-prefo[i][j];
int I = prefi[n][j]-prefi[i][j];
ans+=(O*I);
}
}
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
5468 KB |
Output is correct |
6 |
Correct |
1 ms |
5468 KB |
Output is correct |
7 |
Correct |
2 ms |
5212 KB |
Output is correct |
8 |
Correct |
1 ms |
5468 KB |
Output is correct |
9 |
Correct |
1 ms |
5468 KB |
Output is correct |
10 |
Correct |
1 ms |
5212 KB |
Output is correct |
11 |
Correct |
1 ms |
5468 KB |
Output is correct |
12 |
Correct |
1 ms |
5468 KB |
Output is correct |
13 |
Correct |
1 ms |
5212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
5468 KB |
Output is correct |
6 |
Correct |
1 ms |
5468 KB |
Output is correct |
7 |
Correct |
2 ms |
5212 KB |
Output is correct |
8 |
Correct |
1 ms |
5468 KB |
Output is correct |
9 |
Correct |
1 ms |
5468 KB |
Output is correct |
10 |
Correct |
1 ms |
5212 KB |
Output is correct |
11 |
Correct |
1 ms |
5468 KB |
Output is correct |
12 |
Correct |
1 ms |
5468 KB |
Output is correct |
13 |
Correct |
1 ms |
5212 KB |
Output is correct |
14 |
Correct |
9 ms |
11356 KB |
Output is correct |
15 |
Correct |
2 ms |
8028 KB |
Output is correct |
16 |
Correct |
4 ms |
8540 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
9 ms |
12380 KB |
Output is correct |
19 |
Correct |
6 ms |
12260 KB |
Output is correct |
20 |
Correct |
6 ms |
12124 KB |
Output is correct |
21 |
Correct |
10 ms |
12380 KB |
Output is correct |
22 |
Correct |
10 ms |
12124 KB |
Output is correct |
23 |
Correct |
8 ms |
12124 KB |
Output is correct |
24 |
Correct |
9 ms |
12380 KB |
Output is correct |
25 |
Correct |
9 ms |
12124 KB |
Output is correct |
26 |
Correct |
6 ms |
12120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
5468 KB |
Output is correct |
6 |
Correct |
1 ms |
5468 KB |
Output is correct |
7 |
Correct |
2 ms |
5212 KB |
Output is correct |
8 |
Correct |
1 ms |
5468 KB |
Output is correct |
9 |
Correct |
1 ms |
5468 KB |
Output is correct |
10 |
Correct |
1 ms |
5212 KB |
Output is correct |
11 |
Correct |
1 ms |
5468 KB |
Output is correct |
12 |
Correct |
1 ms |
5468 KB |
Output is correct |
13 |
Correct |
1 ms |
5212 KB |
Output is correct |
14 |
Correct |
9 ms |
11356 KB |
Output is correct |
15 |
Correct |
2 ms |
8028 KB |
Output is correct |
16 |
Correct |
4 ms |
8540 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
9 ms |
12380 KB |
Output is correct |
19 |
Correct |
6 ms |
12260 KB |
Output is correct |
20 |
Correct |
6 ms |
12124 KB |
Output is correct |
21 |
Correct |
10 ms |
12380 KB |
Output is correct |
22 |
Correct |
10 ms |
12124 KB |
Output is correct |
23 |
Correct |
8 ms |
12124 KB |
Output is correct |
24 |
Correct |
9 ms |
12380 KB |
Output is correct |
25 |
Correct |
9 ms |
12124 KB |
Output is correct |
26 |
Correct |
6 ms |
12120 KB |
Output is correct |
27 |
Correct |
239 ms |
150612 KB |
Output is correct |
28 |
Correct |
9 ms |
29796 KB |
Output is correct |
29 |
Correct |
11 ms |
16596 KB |
Output is correct |
30 |
Correct |
2 ms |
2908 KB |
Output is correct |
31 |
Correct |
181 ms |
128316 KB |
Output is correct |
32 |
Correct |
144 ms |
150476 KB |
Output is correct |
33 |
Correct |
141 ms |
150352 KB |
Output is correct |
34 |
Correct |
215 ms |
147160 KB |
Output is correct |
35 |
Correct |
124 ms |
150608 KB |
Output is correct |
36 |
Correct |
140 ms |
150352 KB |
Output is correct |
37 |
Correct |
228 ms |
150640 KB |
Output is correct |
38 |
Correct |
114 ms |
127568 KB |
Output is correct |
39 |
Correct |
107 ms |
128080 KB |
Output is correct |