#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;
const int N = 3e3+5, mod = 1e9+7, sq = 500;
ll answer;
int n,m;
char A[N][N];
int O[N][N],I[N][N];
inline void test_case(){
cin >> n >> m;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
cin >> A[i][j];
O[i][j] = O[i][j-1] + (A[i][j] == 'O');
I[i][j] = I[i-1][j] + (A[i][j] == 'I');
}
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
if(A[i][j] == 'J'){
answer += (O[i][m]-O[i][j])*(I[n][j] - I[i][j]);
}
}
}
cout << answer << endl;
}
main(){
ios::sync_with_stdio(0);
int T = 1;
//cin >> T;
while(T--){
test_case();
}
}
Compilation message
joi2019_ho_t1.cpp:39:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
39 | main(){
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
1484 KB |
Output is correct |
6 |
Correct |
1 ms |
1484 KB |
Output is correct |
7 |
Correct |
1 ms |
1356 KB |
Output is correct |
8 |
Correct |
2 ms |
1484 KB |
Output is correct |
9 |
Correct |
1 ms |
1484 KB |
Output is correct |
10 |
Correct |
1 ms |
1368 KB |
Output is correct |
11 |
Correct |
2 ms |
1484 KB |
Output is correct |
12 |
Correct |
1 ms |
1484 KB |
Output is correct |
13 |
Correct |
1 ms |
1356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
1484 KB |
Output is correct |
6 |
Correct |
1 ms |
1484 KB |
Output is correct |
7 |
Correct |
1 ms |
1356 KB |
Output is correct |
8 |
Correct |
2 ms |
1484 KB |
Output is correct |
9 |
Correct |
1 ms |
1484 KB |
Output is correct |
10 |
Correct |
1 ms |
1368 KB |
Output is correct |
11 |
Correct |
2 ms |
1484 KB |
Output is correct |
12 |
Correct |
1 ms |
1484 KB |
Output is correct |
13 |
Correct |
1 ms |
1356 KB |
Output is correct |
14 |
Correct |
9 ms |
7500 KB |
Output is correct |
15 |
Correct |
3 ms |
4940 KB |
Output is correct |
16 |
Correct |
6 ms |
4300 KB |
Output is correct |
17 |
Correct |
1 ms |
460 KB |
Output is correct |
18 |
Correct |
11 ms |
7980 KB |
Output is correct |
19 |
Correct |
10 ms |
7884 KB |
Output is correct |
20 |
Correct |
10 ms |
7756 KB |
Output is correct |
21 |
Correct |
12 ms |
8012 KB |
Output is correct |
22 |
Correct |
10 ms |
7884 KB |
Output is correct |
23 |
Correct |
10 ms |
7864 KB |
Output is correct |
24 |
Correct |
11 ms |
7916 KB |
Output is correct |
25 |
Correct |
10 ms |
7884 KB |
Output is correct |
26 |
Correct |
10 ms |
7764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
1484 KB |
Output is correct |
6 |
Correct |
1 ms |
1484 KB |
Output is correct |
7 |
Correct |
1 ms |
1356 KB |
Output is correct |
8 |
Correct |
2 ms |
1484 KB |
Output is correct |
9 |
Correct |
1 ms |
1484 KB |
Output is correct |
10 |
Correct |
1 ms |
1368 KB |
Output is correct |
11 |
Correct |
2 ms |
1484 KB |
Output is correct |
12 |
Correct |
1 ms |
1484 KB |
Output is correct |
13 |
Correct |
1 ms |
1356 KB |
Output is correct |
14 |
Correct |
9 ms |
7500 KB |
Output is correct |
15 |
Correct |
3 ms |
4940 KB |
Output is correct |
16 |
Correct |
6 ms |
4300 KB |
Output is correct |
17 |
Correct |
1 ms |
460 KB |
Output is correct |
18 |
Correct |
11 ms |
7980 KB |
Output is correct |
19 |
Correct |
10 ms |
7884 KB |
Output is correct |
20 |
Correct |
10 ms |
7756 KB |
Output is correct |
21 |
Correct |
12 ms |
8012 KB |
Output is correct |
22 |
Correct |
10 ms |
7884 KB |
Output is correct |
23 |
Correct |
10 ms |
7864 KB |
Output is correct |
24 |
Correct |
11 ms |
7916 KB |
Output is correct |
25 |
Correct |
10 ms |
7884 KB |
Output is correct |
26 |
Correct |
10 ms |
7764 KB |
Output is correct |
27 |
Correct |
257 ms |
87948 KB |
Output is correct |
28 |
Correct |
14 ms |
25976 KB |
Output is correct |
29 |
Correct |
19 ms |
7800 KB |
Output is correct |
30 |
Correct |
1 ms |
588 KB |
Output is correct |
31 |
Correct |
197 ms |
72632 KB |
Output is correct |
32 |
Correct |
245 ms |
88388 KB |
Output is correct |
33 |
Correct |
251 ms |
88140 KB |
Output is correct |
34 |
Correct |
247 ms |
84372 KB |
Output is correct |
35 |
Correct |
250 ms |
88464 KB |
Output is correct |
36 |
Correct |
244 ms |
88192 KB |
Output is correct |
37 |
Correct |
348 ms |
88520 KB |
Output is correct |
38 |
Correct |
173 ms |
72516 KB |
Output is correct |
39 |
Correct |
171 ms |
72260 KB |
Output is correct |